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

Re: Sharing code between Smart Device Project and desktop project by lukasz

lukasz
Mon Sep 13 09:02:30 CDT 2004

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" <dan@dontspamme.com> napisa³ w wiadomo¶ci
news:#lra0wYmEHA.3428@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
>
>



Re: Sharing code between Smart Device Project and desktop project by Dan

Dan
Mon Sep 13 10:30:30 CDT 2004

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" <bbla32@op.pl> wrote in message
news:On6cQpZmEHA.1376@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" <dan@dontspamme.com> napisa³ w wiadomo¶ci
> news:#lra0wYmEHA.3428@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
> >
> >
>
>



Re: Sharing code between Smart Device Project and desktop project by Chris

Chris
Mon Sep 13 11:05:54 CDT 2004

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" <dan@dontspamme.com> wrote in message
news:%23fxgbaamEHA.4064@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" <bbla32@op.pl> wrote in message
> news:On6cQpZmEHA.1376@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" <dan@dontspamme.com> napisa³ w wiadomo¶ci
> > news:#lra0wYmEHA.3428@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
> > >
> > >
> >
> >
>
>



Re: Sharing code between Smart Device Project and desktop project by lukasz

lukasz
Mon Sep 13 11:18:10 CDT 2004

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" <dan@dontspamme.com> napisa³ w wiadomo¶ci
news:#fxgbaamEHA.4064@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" <bbla32@op.pl> wrote in message
> news:On6cQpZmEHA.1376@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" <dan@dontspamme.com> napisa³ w wiadomo¶ci
> > news:#lra0wYmEHA.3428@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
> > >
> > >
> >
> >
>
>



Re: Sharing code between Smart Device Project and desktop project by r_z_aret

r_z_aret
Mon Sep 13 13:39:18 CDT 2004

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" <dan@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

Re: Sharing code between Smart Device Project and desktop project by Dan

Dan
Mon Sep 13 15:29:44 CDT 2004

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" <ctacke@spamfree-opennetcf.org> wrote in message
news:uPMaNuamEHA.3392@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" <dan@dontspamme.com> wrote in message
> news:%23fxgbaamEHA.4064@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" <bbla32@op.pl> wrote in message
> > news:On6cQpZmEHA.1376@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" <dan@dontspamme.com> napisa³ w wiadomo¶ci
> > > news:#lra0wYmEHA.3428@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
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: Sharing code between Smart Device Project and desktop project by Nick

Nick
Tue Sep 14 21:07:54 CDT 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).

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