Problem using regular class library project in device project

E

enantiomer

I am using vs.net 2005 and have written a class library of business
objects. The business objects project is for the full .net framework.

The problem is that when I add a reference to the bus objects project
to my device project and try to instantiate a business object, it
always throws a compiler error that says:

"The type 'System.ComponentModel.IDataErrorInfo' is defined in an
assembly that is not referenced. You must add a reference to assembly
'System, Version=2.0.0.0..."

This one happened when I tried this line of code:

Uid uid = new Uid();

Now my base business object which all bus objects extend implements
IDataErrorInfo interface. I notice that this interface is supported in
both the full and compact framework. I have noticed a similar kind of
error when trying to assign instances of datasets in my device project
from my services project as well.

Any ideas on why it is giving me this compile exception? It seems as
though since the bus objects assembly is compiled under the full
framework, when I try to assign a class to it under the compact
framework, any classes/interfaces found under both versions of the
framework although they have the same name, are really defined as
different classes within the GAC (am i right?) and have different
strong name authenticated values. Is this why the compiler error is
being raised?

If this is the case, what is my best bet of using my business objects
in a mobile device project? Is anyone doing this? Thanks for the
help,

Jonathan
 
E

enantiomer

Sounds great! I do have some questions though...

In your moth blog you say "this can be done by creating the file in one
project and then adding a link to it from the other"

How can you add a link to it from the other project? Are you talking
about creating a windows shortcut for every file that is in the
original project? That would be cumbersome.

I also tried the other approach mentioned in your blog: "place the
projects in the same directory and include the code files in both
projects."

This gave me problems, however, when I tried to compile it said
something like

Source file 'D:\InfinID\InfinId.Common\Properties\AssemblyInfo.cs'
could not be opened ('The system cannot find the file specified.
') InfinID.Common.Mobile

Here I just included the original AssemblyInfo.cs class in my new
mobile class library project (which happened to be in the same
directory as the other class library project)... is this the right
approach? Can you explain how to do the first one and also what I was
doing wrong with the second? Appreciate it!

Jonathan
 
D

Daniel Moth

First approach, yes shortcuts (cumbersome yes but what percentage of your
time is spent adding files to a project?).

No idea what you got wrong with the second approach. If you can start again
and document your steps one by one I might be able to help. Obvious things
to check are that you only have on AssemblyInfo, that there are no other
compile errors and that project properties can see the AssemblyInfo
information.

Cheers
Daniel
 
E

enantiomer

Thanks. Figured it out. The properties directory was just missing
that AssemblyInfo class. Now I am going through the grueling task of
putting those compiler directives into all out code. One frustrating
thing is that any class the implements ISerializable will be completely
unusable, since you have to put compiler directives at the beginning of
the line. Also the lack of role based security in the CF is
frustrating as well.

Thanks for all your help Daniel, I really appreciate it!

Jonathan
 
D

Daniel Moth

thing is that any class the implements ISerializable will be completely
unusable, since you have to put compiler directives at the beginning of
Can you elaborate on this? There are a couple of things you can do if don't
mind losing the ISerialzable functionality but I want to make sure I
understood your issue.

Cheers
Daniel
 
E

enantiomer

I dont mind elaborating... We were serializing some of our classes in
order to store them in the database as binary serialized data, thus,
some classes implemented ISerializable. This means that the class
signature went something like this:

public class MySerializedClass : MyBaseClass, ISerializable

and using the #if FULL_FRAME compiler directive cant just filter out
the ISerializable part since it needs to start at the beginning of a
line. I found that instead of doing binary serialization, I can
probably get away with just plain xml serialization using the
XmlSerializer class. It provides pretty much identical functionality
and is supported by the CF.

How does that sound? Any suggestions? Thanks,
Jonathan
 
D

Daniel Moth

So I don't see the showstopper to using the entire class. E.g. you can do
something like this:

public class MySerializedClass : MyBaseClass
#if FULL_FRAME
, ISerializable
#endif


You could even define the ISerializable interface in your netcf project
only. No need to implement, just define the stub so the compiler is happy.

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