.NET Full and CF framework code

G

Guest

Hi,

I'm writing a DLL which will be used for applications written in both the
..NET Full Framework as well as the .NET Compact Framework (CF). Due to the
fact that features from the Full framework have been left out in the CF, the
DLL needs to be written for both environments. I would really prefer to have
1 DLL project which can be ported to the desired project type (full or CF)
for straight compilation instead of having 2 projects - one for full
framework and the other for the CF. This would allow easier version
modifications etc...

Is there any way of writing the code (e.g. using pre-proc directives) such
that only certain segments are compiled depending on the environment used?

Thanks.

Michael--J.
 
G

Guest

Since you must compile against different runtimes you probably can't get it
from the IDE. If you're OK with command-line builds then it's doable as you
can set defines and the runtime to link to.

-Chris
 
G

Guest

I see.

I wouldn't mind using command-line builds. If say i had some code that i had
to use in the CF, i still need to put it in a CF project type correct? And
vice versa with the Full Frameowork?

What are the defines that i need to use? And what arguments do i pass to the
command-line? Would there be any examples available? Thanks.

Michael--J.
 
S

Sergey Bogdanov

E

Ed Kaim

I handle this by using DESKTOP as a preproc definition. Anywhere I want to
use desktop-only functionality, I surround with:

#ifdef DESKTOP
// desktop-only code
#endif

You have to remember to add DESKTOP to the preproc line when compiling for
the desktop (it's also available wrapped through the "project properties"
dialogs). You won't end up with a single binary, but you'll be able to
compile the code for either framework.
 
D

Daniel Moth

1 DLL project which can be ported to the desired project type (full or CF)
for straight compilation instead of having 2 projects - one for full
framework and the other for the CF. This would allow easier version

It really isn't hard and it is straightforward to maintain two projects with
the same source for the two platforms. Include your AssemblyInfo file as
part of the shared code and you can sync the versions that way. If you go
down that road check this out:
http://www.danielmoth.com/Blog/2004/09/share-code-if-fullframe_17.html

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top