473,696 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2 Projects Sharing 1 Set of Files

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. So I've
adopted the approach of having two projects share the same set of files. In
my case, I have two similarly named projects:
DataObjects
DataObjectsCF

The former is for the Desktop app and the latter is for the Compact Framework.

Throughout the many classes shared by these two projects I have some
conditional compilation statements that look like this:
#if (CF)

where 'CF' is used to denote code only for the Pocket PC and conversely
'!CF' is for code only for the Desktop.

I opened up the properties of DataObjectsCF and added the conditional
compilation constant 'CF'. Strangely though, this treated all the files
"looked at" by DataObjects as if I were debugging the Pocket PC app, when
clearly I was working with the Desktop app.

Why is this?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #1
16 2243
There is an issue (at least I classify it as such) where if you have two
projects, in the same solution, that are linking to the same file, then when
that file is open the last project that was loaded into the solution will
take precedence over the others and the conditional constants for this
project will be honored as well as intellisense showing information based on
the references of the last project loaded. In short, if you're sharing files
between projects in the same solution, and one project is targeting the full
framework while the other is targeting the compact framework then you may
see issues, as it appears is the case in this situation. The only workaround
that I'm aware of is to place each project into its own solution. It's not
nice but it's better than dealing with the phantom issues of shared files.
The other option in your situation is to code, and compile, your class
library against the compact framework, using only compact framework classes
that also exist in the full framework, and the class library will be usable
on the desktop as it is retargetable.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discus sions.microsoft .com> wrote in message
news:ED******** *************** ***********@mic rosoft.com...
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. So I've
adopted the approach of having two projects share the same set of files. In my case, I have two similarly named projects:
DataObjects
DataObjectsCF

The former is for the Desktop app and the latter is for the Compact Framework.
Throughout the many classes shared by these two projects I have some
conditional compilation statements that look like this:
#if (CF)

where 'CF' is used to denote code only for the Pocket PC and conversely
'!CF' is for code only for the Desktop.

I opened up the properties of DataObjectsCF and added the conditional
compilation constant 'CF'. Strangely though, this treated all the files
"looked at" by DataObjects as if I were debugging the Pocket PC app, when
clearly I was working with the Desktop app.

Why is this?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #2
Tim,

Thank you for your response. I think you've hit the nail on the head
because so-called "phantom issues" seem to be exactly what I'm experiencing
now. They're scary!

With regard to your latter idea, if I were just to code everything for the
CF then I would manually copy the resultant DLL into the WinForms project?
Put another way, how do I force a class library to always compile for the CF?

--
Robert W.
Vancouver, BC
www.mwtech.com

"Tim Wilson" wrote:
There is an issue (at least I classify it as such) where if you have two
projects, in the same solution, that are linking to the same file, then when
that file is open the last project that was loaded into the solution will
take precedence over the others and the conditional constants for this
project will be honored as well as intellisense showing information based on
the references of the last project loaded. In short, if you're sharing files
between projects in the same solution, and one project is targeting the full
framework while the other is targeting the compact framework then you may
see issues, as it appears is the case in this situation. The only workaround
that I'm aware of is to place each project into its own solution. It's not
nice but it's better than dealing with the phantom issues of shared files.
The other option in your situation is to code, and compile, your class
library against the compact framework, using only compact framework classes
that also exist in the full framework, and the class library will be usable
on the desktop as it is retargetable.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discus sions.microsoft .com> wrote in message
news:ED******** *************** ***********@mic rosoft.com...
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. So I've
adopted the approach of having two projects share the same set of files.

In
my case, I have two similarly named projects:
DataObjects
DataObjectsCF

The former is for the Desktop app and the latter is for the Compact

Framework.

Throughout the many classes shared by these two projects I have some
conditional compilation statements that look like this:
#if (CF)

where 'CF' is used to denote code only for the Pocket PC and conversely
'!CF' is for code only for the Desktop.

I opened up the properties of DataObjectsCF and added the conditional
compilation constant 'CF'. Strangely though, this treated all the files
"looked at" by DataObjects as if I were debugging the Pocket PC app, when
clearly I was working with the Desktop app.

Why is this?

--
Robert W.
Vancouver, BC
www.mwtech.com


Nov 17 '05 #3
> With regard to your latter idea, if I were just to code everything for the
CF then I would manually copy the resultant DLL into the WinForms project? You would just add the class lib assembly (dll) as a reference and use it as
normal.
Put another way, how do I force a class library to always compile for the CF?
Place the code to compile in a smart device project. The project would be
set up to compile against the CF.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discus sions.microsoft .com> wrote in message
news:86******** *************** ***********@mic rosoft.com... Tim,

Thank you for your response. I think you've hit the nail on the head
because so-called "phantom issues" seem to be exactly what I'm experiencing now. They're scary!

With regard to your latter idea, if I were just to code everything for the
CF then I would manually copy the resultant DLL into the WinForms project?
Put another way, how do I force a class library to always compile for the CF?
--
Robert W.
Vancouver, BC
www.mwtech.com

"Tim Wilson" wrote:
There is an issue (at least I classify it as such) where if you have two
projects, in the same solution, that are linking to the same file, then when that file is open the last project that was loaded into the solution will take precedence over the others and the conditional constants for this
project will be honored as well as intellisense showing information based on the references of the last project loaded. In short, if you're sharing files between projects in the same solution, and one project is targeting the full framework while the other is targeting the compact framework then you may see issues, as it appears is the case in this situation. The only workaround that I'm aware of is to place each project into its own solution. It's not nice but it's better than dealing with the phantom issues of shared files. The other option in your situation is to code, and compile, your class
library against the compact framework, using only compact framework classes that also exist in the full framework, and the class library will be usable on the desktop as it is retargetable.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discus sions.microsoft .com> wrote in message
news:ED******** *************** ***********@mic rosoft.com...
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. So I've
adopted the approach of having two projects share the same set of files.
In
my case, I have two similarly named projects:
DataObjects
DataObjectsCF

The former is for the Desktop app and the latter is for the Compact

Framework.

Throughout the many classes shared by these two projects I have some
conditional compilation statements that look like this:
#if (CF)

where 'CF' is used to denote code only for the Pocket PC and

conversely '!CF' is for code only for the Desktop.

I opened up the properties of DataObjectsCF and added the conditional
compilation constant 'CF'. Strangely though, this treated all the files "looked at" by DataObjects as if I were debugging the Pocket PC app, when clearly I was working with the Desktop app.

Why is this?

--
Robert W.
Vancouver, BC
www.mwtech.com


Nov 17 '05 #4
Tim,

Sorry to be so dense about this (and Daniel Moth went to great pains to
explain it to me) but I do have another question.

I've removed the extra parallel projects so things were as before. Now ...
one of my top-level projects is called "Pocket PC". My other top-level
project is called "Desktop". Both reference my class libraries,
"DataObject s" and "Multimedia ".

In the Pocket PC project I set a compiler constant called "CF". Then in
several places within the two class libraries I have #if (CF), #else, and
#endif statements.

My confusion is this: When I rebuild the Pocket PC project I had *thought*
that it would force the two DLLs to be built as if they were CF DLLs,
recognizing the 'CF' compiler constant. But after rebuilding I've checked
the file sizes and they're identical to when I rebuild the Desktop project.
So the CF constant is obviously not being recognized.

Or is it the case that I have to manually add the CF flag into each DLL's
properties each time before I rebuild Pocket PC? That's possible, of course,
but will be such a nuisance.

Hoping I explained my dilemma well.

--
Robert W.
Vancouver, BC
www.mwtech.com
Nov 17 '05 #5
Are you sure that you're still not running into the same issue? Try breaking
all the projects out into there own solutions and build the "common"
assemblies against the CF. So ensure that any class libs that you want to
consume from both the desktop and the device side are built from within a
smart device class library project. Just by building from within a smart
device project you will be targeting the CF. If you have any shared source
files then I'm assuming that this is where you have the #if...#else blocks,
and within a smart device project that contains one of these shared source
files you are defining the CF constant in the project properties. Then you
can add these assemblies as a reference to either a desktop or smart device
project.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discus sions.microsoft .com> wrote in message
news:29******** *************** ***********@mic rosoft.com...
Tim,

Sorry to be so dense about this (and Daniel Moth went to great pains to
explain it to me) but I do have another question.

I've removed the extra parallel projects so things were as before. Now .... one of my top-level projects is called "Pocket PC". My other top-level
project is called "Desktop". Both reference my class libraries,
"DataObject s" and "Multimedia ".

In the Pocket PC project I set a compiler constant called "CF". Then in
several places within the two class libraries I have #if (CF), #else, and
#endif statements.

My confusion is this: When I rebuild the Pocket PC project I had *thought*
that it would force the two DLLs to be built as if they were CF DLLs,
recognizing the 'CF' compiler constant. But after rebuilding I've checked
the file sizes and they're identical to when I rebuild the Desktop project. So the CF constant is obviously not being recognized.

Or is it the case that I have to manually add the CF flag into each DLL's
properties each time before I rebuild Pocket PC? That's possible, of course, but will be such a nuisance.

Hoping I explained my dilemma well.

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #6
Tim,

I just did as you said. I created a new solution, copied the required CF
related project folder underneath it (Pocket PC, DataObjects, and Multimedia
projects), and then added these projects into the solution. I rebuilt
everything.

Still, I got the same error as before:
An unhandled exception of type 'System.TypeLoa dException' occurred in PP.exe

Additional information: Could not load type System.Drawing. Image from
assembly System.Drawing, Version=1.0.500 0.0, Culture=neutral ,
PublicKeyToken= B03F5F7F11D50A3 A.
Maybe my interpretation is incorrect, but I assume this means that the
Multimedia project is STILL being compiled as an X86 WinForms one.

For this project I've pretty much given up on sharing DLL code. The only
fullproof method I've found is to build parallel, often identical, code
within the actual PocketPC project. That obviously compiles as CF-compliant
code whereas *I* can't seem to get it to do so if it's in a DLL ... even if
it's a CF-only solution as you've just instructed me to do.

Frustrating!

--
Robert W.
Vancouver, BC
www.mwtech.com

"Tim Wilson" wrote:
Are you sure that you're still not running into the same issue? Try breaking
all the projects out into there own solutions and build the "common"
assemblies against the CF. So ensure that any class libs that you want to
consume from both the desktop and the device side are built from within a
smart device class library project. Just by building from within a smart
device project you will be targeting the CF. If you have any shared source
files then I'm assuming that this is where you have the #if...#else blocks,
and within a smart device project that contains one of these shared source
files you are defining the CF constant in the project properties. Then you
can add these assemblies as a reference to either a desktop or smart device
project.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discus sions.microsoft .com> wrote in message
news:29******** *************** ***********@mic rosoft.com...
Tim,

Sorry to be so dense about this (and Daniel Moth went to great pains to
explain it to me) but I do have another question.

I've removed the extra parallel projects so things were as before. Now

....
one of my top-level projects is called "Pocket PC". My other top-level
project is called "Desktop". Both reference my class libraries,
"DataObject s" and "Multimedia ".

In the Pocket PC project I set a compiler constant called "CF". Then in
several places within the two class libraries I have #if (CF), #else, and
#endif statements.

My confusion is this: When I rebuild the Pocket PC project I had *thought*
that it would force the two DLLs to be built as if they were CF DLLs,
recognizing the 'CF' compiler constant. But after rebuilding I've checked
the file sizes and they're identical to when I rebuild the Desktop

project.
So the CF constant is obviously not being recognized.

Or is it the case that I have to manually add the CF flag into each DLL's
properties each time before I rebuild Pocket PC? That's possible, of

course,
but will be such a nuisance.

Hoping I explained my dilemma well.

--
Robert W.
Vancouver, BC
www.mwtech.com


Nov 17 '05 #7
Just out of curiosity (and to learn)

Why not create 3 common classes, one for shared code, one for the CF and
one for the normal framework?

-Mark

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 17 '05 #8
Mark,

I'm certainly not the expert here, but when I looked at this, I discovered
so many required cross references that I didn't know if it would work
correctly. But maybe somebody else on here might have some more experienced
views on your question.

--
Robert W.
Vancouver, BC
www.mwtech.com

"Mark Nijhof" wrote:
Just out of curiosity (and to learn)

Why not create 3 common classes, one for shared code, one for the CF and
one for the normal framework?

-Mark

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com

Nov 17 '05 #9
Let me try to get my head around what you're doing a little better. You have
two class library projects that each output a dll (assembly) - DataObjects
and Multimedia - correct? You need to use both of these dlls on the desktop
and on a device, correct? I assume that both of these projects are smart
device projects? Do you have any code that is shared between these projects?

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discus sions.microsoft .com> wrote in message
news:61******** *************** ***********@mic rosoft.com...
Tim,

I just did as you said. I created a new solution, copied the required CF
related project folder underneath it (Pocket PC, DataObjects, and Multimedia projects), and then added these projects into the solution. I rebuilt
everything.

Still, I got the same error as before:
An unhandled exception of type 'System.TypeLoa dException' occurred in PP.exe
Additional information: Could not load type System.Drawing. Image from
assembly System.Drawing, Version=1.0.500 0.0, Culture=neutral ,
PublicKeyToken= B03F5F7F11D50A3 A.
Maybe my interpretation is incorrect, but I assume this means that the
Multimedia project is STILL being compiled as an X86 WinForms one.

For this project I've pretty much given up on sharing DLL code. The only
fullproof method I've found is to build parallel, often identical, code
within the actual PocketPC project. That obviously compiles as CF-compliant code whereas *I* can't seem to get it to do so if it's in a DLL ... even if it's a CF-only solution as you've just instructed me to do.

Frustrating!

--
Robert W.
Vancouver, BC
www.mwtech.com

"Tim Wilson" wrote:
Are you sure that you're still not running into the same issue? Try breaking all the projects out into there own solutions and build the "common"
assemblies against the CF. So ensure that any class libs that you want to consume from both the desktop and the device side are built from within a smart device class library project. Just by building from within a smart
device project you will be targeting the CF. If you have any shared source files then I'm assuming that this is where you have the #if...#else blocks, and within a smart device project that contains one of these shared source files you are defining the CF constant in the project properties. Then you can add these assemblies as a reference to either a desktop or smart device project.

--
Tim Wilson
..NET Compact Framework MVP

"Robert W." <Ro*****@discus sions.microsoft .com> wrote in message
news:29******** *************** ***********@mic rosoft.com...
Tim,

Sorry to be so dense about this (and Daniel Moth went to great pains to explain it to me) but I do have another question.

I've removed the extra parallel projects so things were as before. Now
....
one of my top-level projects is called "Pocket PC". My other

top-level project is called "Desktop". Both reference my class libraries,
"DataObject s" and "Multimedia ".

In the Pocket PC project I set a compiler constant called "CF". Then in several places within the two class libraries I have #if (CF), #else, and #endif statements.

My confusion is this: When I rebuild the Pocket PC project I had *thought* that it would force the two DLLs to be built as if they were CF DLLs,
recognizing the 'CF' compiler constant. But after rebuilding I've checked the file sizes and they're identical to when I rebuild the Desktop

project.
So the CF constant is obviously not being recognized.

Or is it the case that I have to manually add the CF flag into each DLL's properties each time before I rebuild Pocket PC? That's possible, of

course,
but will be such a nuisance.

Hoping I explained my dilemma well.

--
Robert W.
Vancouver, BC
www.mwtech.com


Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1946
by: Simon Neve | last post by:
Hello, This question is related to sharing .Net projects across solutions and is reposted from the SourceSafe group. We have several different solutions and want to share common assemblies across them. Is it best to share the project and its files to each solution (each solution has it's own shared project), or have each solution point to the same file location of the project?
5
5372
by: cybertof | last post by:
Hi ! What is the common use of sharing a single .cs across multiple project files ? I think it's to share common classes between projects. I have actually a .cs file shared accross multiple projects in a same solution. It's nice to have a common "set" of Classes. Is this the only way to share classes between projects ?
1
3655
by: JoeS | last post by:
Is there anyway to share a single pch file between projects in VC 7.0? I have 300+ projects each of which creates its own pch. All projects include the exact same header files in the precompiled header. Its takes about 7 seconds to create the precompiled header for each project. That's 35 minutes spent creating precompiled headers for all project! All of the projects use PDB files for debug info. I tried creating Precomp.pch in project...
0
1206
by: Daniel | last post by:
Hi! I have several projects (approx 50) that includes basically the same files such as <atlcom.h> and <comdef.h>. The projects are set up to use a precompiled header wich includes these header files (<atlcom.h> and <comdef.h>) and that works fine. But since these files are used in all the projects and every project have a separate precompiled header these files get compiled a lot of times. Is it possible to do anything about this? Is it...
0
1565
by: Chris Morse | last post by:
Hi, I am creating a solution with two projects. Basically, they share a few common class files and forms. I finished one project, and it compiles and runs fine. I just finished bringing in the second project, and I get the following error on one of the forms when it is invoked: ----------------------------------------------------------------- An unhandled exception of type
3
3299
by: Ron L | last post by:
I have an application that I am developing that is a front end for a SQL database. We will also be developing a subset of the UI that will work as a (mainly) standalone client that will make a connection to the database, copy the relevant data to a local file, and disconnect from the database. The users will then be able to make modifications using the UI, and when a connection is available they can connect and upload their changes. ...
2
1297
by: Andrew E Chapman | last post by:
I have a VB.NET class library project and two other VB.NET projects that depend on that class library, ie: Class library --Project 1 --Project 2 Currently, as you'd expect, when I compile this, each of Project 1 and 2 end up with an exe and a dll. However, I don't want the project to be distributed with a dll, so is it possible to add the files to each of the Projects
2
3019
by: Magnus Bergh | last post by:
I have a solution which contains multiple projects (different applications). Every project use the same typed dataset (and also a few other shared code files). I tried to remove the dataset.xsd from the project and add it as a linked items (files in a different direcory on disk) instead but this cause errors in the designer when I try to open any form using the dataset. If I change back back to include the dataset in the project it...
2
1970
by: Jeff Dege | last post by:
I'm working with a group that's been doing C++ coding for quite a long time, now, and in that environment we've pretty much worked out development practices that serve us well. We've been doing more and more, over the last few years, in C# and ASP.NET. Some web apps, some background services. In our C++ code base, we have a fair number of statically-linked libraries that contain code we share between projects. At this point, in our...
0
8666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9145
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9010
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8853
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4611
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3033
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1992
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.