473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Sharing code between Smart Device Project and desktop project

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
7 3077
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Casey Entzi | last post by:
I have Visual C#.net and got visual studio 2003 with it as a package. My question is, can I create programs for Smart Devices? In the help file it walks you through it, but it tells you to create...
2
by: Comcrap | last post by:
I'm trying to create a custom control for a smart device, and all the walkthroughs on msdn list a "Windows Control Library" project type under the smart device application wizard. I don't have...
2
by: Sreedharan | last post by:
Hi, I am using C#. Is there no Join method (in thread class)for Smart device application? And Also i noticed that Name property isn't there(got compiler error when trying to use them) Is this...
3
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be...
16
by: Robert W. | last post by:
I'm building a solution that has 1 component for the Desktop and 1 component for the Pocket PC. (Though this isn't a mobile question). I have a data library that will be shared on both platforms....
1
by: Smith | last post by:
Are attributed ATL projects be supported under Whidbey for Smart Devices? The New ATL Project dialog box doesn't have the 'Attributed' check box for smart devices projects in Beta1, but Win32...
2
by: David | last post by:
How do I share code across files in C#, without including a reference to a class library. Here's what I want to do. I have a device I want to talk to. It's a machine in a factory. It can talk...
0
by: Jan | last post by:
Hi, I am working on a smart device application. The application should run properly on two different devices with two different resolutions (240*320 and 240*240). I know in the 'normal'...
2
by: Paulson | last post by:
bye Paulson Hi all I want to create a small application on my mobile(SamsungC200) As a first step I made a solution and added Project SamrtDeviceApplication I named it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.