Question

I read this post which apparently solves the issue with WPF app publishing which has SQL Server Compact dependency. I went through all the steps prescribed by the author of this post but it just doesn't work for me. Once I add all the DLLs from SQL Server Compact "private" folder my app crashes on startup. The difference is that I use .NET 4.5 while the example deals with 4.0 I am not sure if that is the core of the problem but it just doesn't work with those settings.

My app is crashing with the following exception :

System.Windows.Markup.XamlParseException

Here is my app.config (including add on from the article ) :

<?xml version="1.0"?>
<configuration>
   <connectionStrings>
      <add name="TypeAppRelease.Properties.Settings.MyDatabase_1ConnectionString"
           connectionString="Data Source=D:\XXXXXX\XXXXX\XXXXXXX\externals\MyDatabase#1.sdf;Password=XXXXXXX;Persist Security Info=True"
           providerName="Microsoft.SqlServerCe.Client.4.0"  />
   </connectionStrings>
   <system.data>    
      <DbProviderFactories>      
         <remove invariant="System.Data.SqlServerCe.4.0"/>      
         <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, 
               Culture=neutral, 
                PublicKeyToken=89845dcd8080cc91"/>    
      </DbProviderFactories>  
   </system.data>
   <startup> 
       <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
   </startup>
</configuration>

One more thing. I came to this because doing just ClickOnce publishing produced installation file which didn't work complaining that

The application is missing required files ....

So that lead me to the solution I linked above which also seems not to work.

Update:

I would like to extend on this problem because until not I haven't resolved it. I decided to put aside ClickOnce deployment and just test Debug/Release builds on 2 machines:1) With SQL Compact Server installed ;2) Has only NET framework installed.

The App works ok on the first machine and fails on the second.That is pretty logical because the first one has Compact SQL installed and running.

Next I removed the server installation from the first machine and ran the app again.It still works , but not for the second PC .The error I am getting is

System.IO.FileLoadException

I can't figure out why I am getting it and why I am not getting the same on the first machine.

Maybe it is 64 /32 bit OS thing? PC1 runs Windows 7 64bit while PC2 x86.

Was it helpful?

Solution

I you use ADO.NET objects (SqlCeCommand, DataSet) instead of Entity Framework (as described in my blog post) you must reference System.Data.SqlServerCe.dll in your project folder (assembly version 4.0.0.1) and NOT the dll in your GAC (assembly version 4.0.0.0). I have updated my blog post with that information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top