views:

928

answers:

4

Hi,

I have a C# windows mobile application originally created in VS2005 that was used to create a test database. However, now that I've included the C# code into a VS2008 project and re-setup the SQL references, I receive the following error:

An unhandled exception of type 'System.TypeLoadException' occurred in Unknown Module.

Additional information: File or assembly name 'System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=3BE235DF1C8D2AD3', or one of its dependencies, was not found.

The reference path appears to be good. Any ideas?

Thanks,

A: 

Have you set your project to be a .Net Compact Framework 3.5 project? I imagine that if it is still being loaded as a 2.0 project it would have problems loading assemblies from the 3.5 framework.

Fredrik Mörk
+3  A: 

Try to drop and readd the Reference.

A quick glance at my own GAC shows that library to have an incorrect PublicKeyToken

Assembly:         System.Data.SqlServerCe
Culture:          Neutral
Version:          3.5.0.0
Public Key Token: 89845dcd8080cc91

After a quick google, it looks like your referencing the desktop platform version instead of the device platform version.

See this post here

http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/f509138c-8442-4bef-916a-a97bda4721ee

Running Sql Mobile applications on the desktop is not a supported scenario (except your desktop is a TabletPC).

The public key token for System.Data.SqlServerCe (desktop platform) is 3be235df1c8d2ad3

The public key token for System.Data.SqlServerCe (device platform) is 89845dcd8080cc91

Eoin Campbell
I think the post in the about the public keys is wrong.
NitroxDM
A: 

Im guessing your problem is that you can load the named assembly but one of it's dependencies is still referenced as the 2.0 version from the previous project setup. Go through all your referenced assemblies and make sure they are all from the same version of the framework. (That's actually not a requirement that they all are from the same version but it does make life easier in the long run). The problem is that if you use a v3.5 that will have v3.5 dependencies and if you only refrerence the v2.0 assembly you'll get the above error

Rune FS
A: 

I had the same issue. What worked for me was to completely remove the following from the Pocket PC device:

<MY APP>
Microsoft .Net CF 3.5 EN-String R...
Microsoft .Net CF 3.5
SQLServerCompact 3.5 Tools EN
SQLServerCompact 3.5 Repl
SQLServerCompact 3.5 Core

Then installing: NETCFv35.ppc.armv4.cab ( Microsoft .Net CF 3.5 ) NETCFv35.Messages.EN.cab ( Microsoft .Net CF 3.5 EN-String R... ) sqlce.ppc.wce4.armv4.CAB ( SQLServerCompact 3.5 Core )

You might be able to just remove and reinstall the SQLServerCompact 3.5 packages. That is what worked for me.

NitroxDM