views:

1426

answers:

5

Hi!

We have a situation where a C# application is working with SQL CE 3.5 . To allow for a legacy program to use some of its features we have produced a C++ dll which uses interop to extract the info that it needs from the C# program. For this to work, the C#-program needs to access the database. Its not a very complex scenario.

When trying to deploy with a private install some problems occur though. There is no problem with the C# program, it can access the database and work with it without any problems.

But when trying to access functions in the C#-program through the C++ interop which forces the C#-program to access the database, we get a crash with the exception saying that "...the Provider: System.Data.SqlServerCe.3.5 is not installed".

This is obviously because we cannot add a App.config file to the executing program.

How can we get around this? Is there another way to fix this? Any other forms of SQL CE 3.5 install methods are out of the question. So we must get this to work.

Regards,

P

Edit:

I'm not working against SQL CE directly, but through Linq2SQL. I have tried to add config files to all my dll's, it does not help. It seems to only matter if the executable file have got a app.config.

The exception thrown says - The provider System.Data.SqlServerCe.3.5 is not installed.

And the latest function to be called according to the stack trace is System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Initialize(...).

Edit 2

I have added all the files necessery for the deployment to work. As I wrote above, it works if I use the program dll (which uses Linq 2 Sql) through a .net executable with a app.config file that specifies where to look for the SQL CE 3.5 dll. Deployment will not work with only the files, an app.config file is necessary.

The problem is that we have to use the dll file through a C++ executable which have no means of telling .net where to look for the Sql Ce 3.5 dll.

A: 

You can add a foo.dll.config file and make sure it lives alongside the DLL. You just need to make sure that you have code in your DLL to determine where it lives on disk, and read the configuration from the same location.

Good luck!

OJ
+1  A: 

add the following files to your application folder:

  • sqlceca35.dll
  • sqlcecompact35.dll
  • sqlceer35E.dll
  • sqlceme35.dll
  • sqlceoledb35.dll
  • sqlceqp35.dll
  • sqlcese35.dll
  • System.Data.SqlServerCe.dll

then it will work.

that is necessary if you have not explicitely installed sql server ce 3.5 on the target machine (which is case for most deployments i think).

Joachim Kerschbaumer
A: 

This is obviously because we cannot add a App.config file to the executing program.

Why not? Okay, so Visual Studio won't automatically build the config file and rename it and move it to the output directory, but have you tried a .exe.config file alongside your C++ application?

Sunlight
A: 

I have also seen an instance where the System.Data.SqlServerCe.dll in the GAC was the wrong file version and I had replace the dll in the GAC from a cmd command prompt.

The point about the files having to be in the folder is true - unless the GAC gets itself confused by have multiple versions

A: 

Do not use LINQ, but use SqlCeConnection, SqlCeCommand etc for the methods you call from your C++ program

ErikEJ