By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,984 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

Sharing code between Smart Device Project and desktop project

P: n/a
Dan
I'd like to have a set of more-or-less common code which I want to use for
both desktop and smart device projects. I have two questions:

1. How can I set up conditional compile directives for those parts of the
code which are different on desktop and smart device projects
2. How can I actually share the same .cs source code files between the two
projects. If I try to open a smart device project and add the files which
are in the desktop project's directory, those files get copied into the
smart device project's directory. Thus, changes which I make in one project
don't get applied to the other one. On the other hand, if I define the
smart device project in the same directory as the desktop project, I
overwrite files in the desktop project directory (in particular
AssemblyInfo.cs-- I can rename the output files to distinguish between the
assemblies for the two projects).

Thanks...

Dan
Nov 16 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
1. Add your own directive in the projects' properties (add "SMARTDEVICE"
after "DEBUG, TRACE"). Then in code use:

#if SMARTDEVICE
....
#else
....
#endif
2. Make two solutions: YourAppDesktop & YourAppDevice. To one solution
(arbitrary) add new library project YourAppLibrary which will contain the
shared files; it'll be compiled to a DLL. The to the other solution add an
EXISTING project: YourAppLibrary. Now, assuming you have added main projects
to both solutions (say, YourAppProjectDesktop & YourAppProjectDevice),
choose the projects' nodes, then subnode References, and add new reference.
Choose 3rd tab, choose YourAppLibrary.

Summarizing:
YourAppDesktop solution
YourAppLibrary (new)
YourAppProjectDesktop
reference to YourAppLibrary (not DLL, but project)
YourAppDevice solution
YourAppLibrary (existing, from Desktop's solution)
YourAppProjectDevice
reference to YourAppLibrary (not DLL, but project)

The disadvantage is both solutions now need a DLL, but I don't know of an
other method to share sources.
Użytkownik "Dan" <da*@dontspamme.com> napisał w wiadomości
news:#l**************@TK2MSFTNGP14.phx.gbl...
I'd like to have a set of more-or-less common code which I want to use for
both desktop and smart device projects. I have two questions:

1. How can I set up conditional compile directives for those parts of the
code which are different on desktop and smart device projects
2. How can I actually share the same .cs source code files between the two
projects. If I try to open a smart device project and add the files which
are in the desktop project's directory, those files get copied into the
smart device project's directory. Thus, changes which I make in one project don't get applied to the other one. On the other hand, if I define the
smart device project in the same directory as the desktop project, I
overwrite files in the desktop project directory (in particular
AssemblyInfo.cs-- I can rename the output files to distinguish between the
assemblies for the two projects).

Thanks...

Dan

Nov 16 '05 #2

P: n/a
Dan
Thanks for the conditional compile advice. However, I think there's a
problem with answer 2: "YourAppLibrary" also will need to be compiled as
both a Desktop and SmartDevice DLL, otherwise it doesn't run properly on the
smartdevice (at least that's been my experience).

Dan
"lukasz" <bb****@op.pl> wrote in message
news:On**************@TK2MSFTNGP12.phx.gbl...
1. Add your own directive in the projects' properties (add "SMARTDEVICE"
after "DEBUG, TRACE"). Then in code use:

#if SMARTDEVICE
...
#else
...
#endif
2. Make two solutions: YourAppDesktop & YourAppDevice. To one solution
(arbitrary) add new library project YourAppLibrary which will contain the
shared files; it'll be compiled to a DLL. The to the other solution add an
EXISTING project: YourAppLibrary. Now, assuming you have added main projects to both solutions (say, YourAppProjectDesktop & YourAppProjectDevice),
choose the projects' nodes, then subnode References, and add new reference. Choose 3rd tab, choose YourAppLibrary.

Summarizing:
YourAppDesktop solution
YourAppLibrary (new)
YourAppProjectDesktop
reference to YourAppLibrary (not DLL, but project)
YourAppDevice solution
YourAppLibrary (existing, from Desktop's solution)
YourAppProjectDevice
reference to YourAppLibrary (not DLL, but project)

The disadvantage is both solutions now need a DLL, but I don't know of an
other method to share sources.
Użytkownik "Dan" <da*@dontspamme.com> napisał w wiadomości
news:#l**************@TK2MSFTNGP14.phx.gbl...
I'd like to have a set of more-or-less common code which I want to use for both desktop and smart device projects. I have two questions:

1. How can I set up conditional compile directives for those parts of the code which are different on desktop and smart device projects
2. How can I actually share the same .cs source code files between the two projects. If I try to open a smart device project and add the files which are in the desktop project's directory, those files get copied into the
smart device project's directory. Thus, changes which I make in one

project
don't get applied to the other one. On the other hand, if I define the
smart device project in the same directory as the desktop project, I
overwrite files in the desktop project directory (in particular
AssemblyInfo.cs-- I can rename the output files to distinguish between the assemblies for the two projects).

Thanks...

Dan


Nov 16 '05 #3

P: n/a
Right. Instead runtime checks should be done. A static constructor to
check the current OS is the simplest method, then all methods can be
redirected based on that check.

-Chris
"Dan" <da*@dontspamme.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Thanks for the conditional compile advice. However, I think there's a
problem with answer 2: "YourAppLibrary" also will need to be compiled as
both a Desktop and SmartDevice DLL, otherwise it doesn't run properly on the smartdevice (at least that's been my experience).

Dan
"lukasz" <bb****@op.pl> wrote in message
news:On**************@TK2MSFTNGP12.phx.gbl...
1. Add your own directive in the projects' properties (add "SMARTDEVICE"
after "DEBUG, TRACE"). Then in code use:

#if SMARTDEVICE
...
#else
...
#endif
2. Make two solutions: YourAppDesktop & YourAppDevice. To one solution
(arbitrary) add new library project YourAppLibrary which will contain the
shared files; it'll be compiled to a DLL. The to the other solution add an EXISTING project: YourAppLibrary. Now, assuming you have added main

projects
to both solutions (say, YourAppProjectDesktop & YourAppProjectDevice),
choose the projects' nodes, then subnode References, and add new

reference.
Choose 3rd tab, choose YourAppLibrary.

Summarizing:
YourAppDesktop solution
YourAppLibrary (new)
YourAppProjectDesktop
reference to YourAppLibrary (not DLL, but project)
YourAppDevice solution
YourAppLibrary (existing, from Desktop's solution)
YourAppProjectDevice
reference to YourAppLibrary (not DLL, but project)

The disadvantage is both solutions now need a DLL, but I don't know of an other method to share sources.
Użytkownik "Dan" <da*@dontspamme.com> napisał w wiadomości
news:#l**************@TK2MSFTNGP14.phx.gbl...
I'd like to have a set of more-or-less common code which I want to use

for both desktop and smart device projects. I have two questions:

1. How can I set up conditional compile directives for those parts of the code which are different on desktop and smart device projects
2. How can I actually share the same .cs source code files between the two projects. If I try to open a smart device project and add the files which are in the desktop project's directory, those files get copied into the smart device project's directory. Thus, changes which I make in one

project
don't get applied to the other one. On the other hand, if I define the smart device project in the same directory as the desktop project, I
overwrite files in the desktop project directory (in particular
AssemblyInfo.cs-- I can rename the output files to distinguish between the assemblies for the two projects).

Thanks...

Dan



Nov 16 '05 #4

P: n/a
I haven't done any smart device project so I weren't aware of the problem,
though it makes sense since it uses a different framework (CF). See if you
can batch build the shared DLL for both desktop Framework & CF (Build |
Batch Build), or whether a macro would allow you to choose compilation
framework depending on active project.

Użytkownik "Dan" <da*@dontspamme.com> napisał w wiadomości
news:#f**************@TK2MSFTNGP14.phx.gbl...
Thanks for the conditional compile advice. However, I think there's a
problem with answer 2: "YourAppLibrary" also will need to be compiled as
both a Desktop and SmartDevice DLL, otherwise it doesn't run properly on the smartdevice (at least that's been my experience).

Dan
"lukasz" <bb****@op.pl> wrote in message
news:On**************@TK2MSFTNGP12.phx.gbl...
1. Add your own directive in the projects' properties (add "SMARTDEVICE"
after "DEBUG, TRACE"). Then in code use:

#if SMARTDEVICE
...
#else
...
#endif
2. Make two solutions: YourAppDesktop & YourAppDevice. To one solution
(arbitrary) add new library project YourAppLibrary which will contain the
shared files; it'll be compiled to a DLL. The to the other solution add an EXISTING project: YourAppLibrary. Now, assuming you have added main

projects
to both solutions (say, YourAppProjectDesktop & YourAppProjectDevice),
choose the projects' nodes, then subnode References, and add new

reference.
Choose 3rd tab, choose YourAppLibrary.

Summarizing:
YourAppDesktop solution
YourAppLibrary (new)
YourAppProjectDesktop
reference to YourAppLibrary (not DLL, but project)
YourAppDevice solution
YourAppLibrary (existing, from Desktop's solution)
YourAppProjectDevice
reference to YourAppLibrary (not DLL, but project)

The disadvantage is both solutions now need a DLL, but I don't know of an other method to share sources.
Użytkownik "Dan" <da*@dontspamme.com> napisał w wiadomości
news:#l**************@TK2MSFTNGP14.phx.gbl...
I'd like to have a set of more-or-less common code which I want to use

for both desktop and smart device projects. I have two questions:

1. How can I set up conditional compile directives for those parts of the code which are different on desktop and smart device projects
2. How can I actually share the same .cs source code files between the two projects. If I try to open a smart device project and add the files which are in the desktop project's directory, those files get copied into the smart device project's directory. Thus, changes which I make in one

project
don't get applied to the other one. On the other hand, if I define the smart device project in the same directory as the desktop project, I
overwrite files in the desktop project directory (in particular
AssemblyInfo.cs-- I can rename the output files to distinguish between the assemblies for the two projects).

Thanks...

Dan



Nov 16 '05 #5

P: n/a
I use eVC 3, eVC 4, and VC 6 with the same source code. I suspect you
are using VS.NET for "big" Windows (desktop) and CE, so I'm not sure
how relevant my experience will be. But see details below.

On Mon, 13 Sep 2004 08:24:42 -0400, "Dan" <da*@dontspamme.com> wrote:
I'd like to have a set of more-or-less common code which I want to use for
both desktop and smart device projects. I have two questions:

1. How can I set up conditional compile directives for those parts of the
code which are different on desktop and smart device projects
I suggest checking a thread called "Compiler Directive" in
microsoft.public.pocketpc.developer around 1 April 2004

2. How can I actually share the same .cs source code files between the two
projects. If I try to open a smart device project and add the files which
are in the desktop project's directory, those files get copied into the
smart device project's directory. Thus, changes which I make in one project
don't get applied to the other one. On the other hand, if I define the
smart device project in the same directory as the desktop project, I
overwrite files in the desktop project directory (in particular
AssemblyInfo.cs-- I can rename the output files to distinguish between the
assemblies for the two projects).
I use eVC 3, eVC 4, and VC 6 with the same source code. Project->Add
Files has never copied files over when I've used it. I do need to put
the eVC 3 and eVC 4 workspace/project files (.vcw, .vcp, etc.) in
separate directories so _they_ don't overwrite each other. For eVC 3
and eVC 4, I define a workspace (.vcw) for each of my programs, and
then a separate project (.vcp) for each platform (SDK). Each of those
projects sends its output to a different place.
The following is a _crude_ diagram:
program main - shared source code
desktop
x86rel - output for release builds for x86 ("big" Windows)
x86dbg - output for debug builds for x86
Pocket PC
mipsrel - output for release builds for MIPS (Pocket PC)
mipsdbg - output for debug builds for MIPS (Pocket PC)
... etc.


Thanks...

Dan


-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com
Nov 16 '05 #6

P: n/a
Dan
Chris--

Thanks very much, but I'm not sure that follow. Are you saying that I can
compile a library against the desktop framework and then run that library on
a smart device, as long as I check the OS for those methods which are
implemented differently on the SmartDevice?

Dan

"Chris Tacke, eMVP" <ct****@spamfree-opennetcf.org> wrote in message
news:uP**************@TK2MSFTNGP15.phx.gbl...
Right. Instead runtime checks should be done. A static constructor to
check the current OS is the simplest method, then all methods can be
redirected based on that check.

-Chris
"Dan" <da*@dontspamme.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Thanks for the conditional compile advice. However, I think there's a
problem with answer 2: "YourAppLibrary" also will need to be compiled as
both a Desktop and SmartDevice DLL, otherwise it doesn't run properly on the
smartdevice (at least that's been my experience).

Dan
"lukasz" <bb****@op.pl> wrote in message
news:On**************@TK2MSFTNGP12.phx.gbl...
1. Add your own directive in the projects' properties (add "SMARTDEVICE" after "DEBUG, TRACE"). Then in code use:

#if SMARTDEVICE
...
#else
...
#endif
2. Make two solutions: YourAppDesktop & YourAppDevice. To one solution
(arbitrary) add new library project YourAppLibrary which will contain the shared files; it'll be compiled to a DLL. The to the other solution
add an EXISTING project: YourAppLibrary. Now, assuming you have added main

projects
to both solutions (say, YourAppProjectDesktop & YourAppProjectDevice),
choose the projects' nodes, then subnode References, and add new

reference.
Choose 3rd tab, choose YourAppLibrary.

Summarizing:
YourAppDesktop solution
YourAppLibrary (new)
YourAppProjectDesktop
reference to YourAppLibrary (not DLL, but project)
YourAppDevice solution
YourAppLibrary (existing, from Desktop's solution)
YourAppProjectDevice
reference to YourAppLibrary (not DLL, but project)

The disadvantage is both solutions now need a DLL, but I don't know of an other method to share sources.
Użytkownik "Dan" <da*@dontspamme.com> napisał w wiadomości
news:#l**************@TK2MSFTNGP14.phx.gbl...
> I'd like to have a set of more-or-less common code which I want to
use for
> both desktop and smart device projects. I have two questions:
>
> 1. How can I set up conditional compile directives for those parts
of the
> code which are different on desktop and smart device projects
> 2. How can I actually share the same .cs source code files between
the two
> projects. If I try to open a smart device project and add the files

which
> are in the desktop project's directory, those files get copied into the > smart device project's directory. Thus, changes which I make in one
project
> don't get applied to the other one. On the other hand, if I define the > smart device project in the same directory as the desktop project, I
> overwrite files in the desktop project directory (in particular
> AssemblyInfo.cs-- I can rename the output files to distinguish

between the
> assemblies for the two projects).
>
> Thanks...
>
> Dan
>
>



Nov 16 '05 #7

P: n/a
2. How can I actually share the same .cs source code files between the two
projects. If I try to open a smart device project and add the files which
are in the desktop project's directory, those files get copied into the
smart device project's directory. Thus, changes which I make in one
project
don't get applied to the other one. On the other hand, if I define the
smart device project in the same directory as the desktop project, I
overwrite files in the desktop project directory (in particular
AssemblyInfo.cs-- I can rename the output files to distinguish between the
assemblies for the two projects).


Make sure that your 'shared' code is created as a .NET CF library, rather
than a full framework library. Then extend that assembly with another one
that contains your full framework specific code.

The full framework can ran a .NET CF library as it is merely a sub set of
the full framework, but not the other way around.

Nick
Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.