Certain symbols in application path prevent SQL Server Compact from loading - by Steve Rukuts

Status : 

  Not Reproducible<br /><br />
		The product team could not reproduce this item with the description and steps provided.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


3
0
Sign in
to vote
ID 692895 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 10/3/2011 4:05:00 PM
Access Restriction Public

Description

When System.Data.SqlServerCe has been copied to a path that contains certain symbols, the application will crash with the following error message:

System.Data.SqlServerCe.SqlCeException: Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8482. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.

The workaround for this issue that I found was to rename the directory. The application directory was called "C#", renaming it to "CSharp" solved the issue. I found this by using ReSharper to step through System.Data.SqlServerCe to find this line in NativeMethods.LoadNativeBinaries():

string localPath = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;

The Uri class ignores everything after the #, meaning that if the path is "c:\applications\c#\myapp1\bin\debug", the path will be truncated to "c:\applications\c".
Sign in to post a comment.
Posted by Fifimoletadu on 11/11/2014 at 8:06 AM
Change the step 5 in my previous message to:
5. Create a file named %ExeName%.config in the path from step 2. %ExeName% represents the name of the executable file WITH extension (ex.: app.exe);
Posted by Fifimoletadu on 11/11/2014 at 6:47 AM
The bug exists in SQL Server Compact 4.0 SP1.

The following conditions must all be true to reproduce it:
a) the application uses private deployment of SQL Server Compact;
b) the path to the private version of System.Data.SqlServerCe.dll contains the sharp symbol;
c) the private SQL Server Compact files - System.Data.SqlServerCe.dll and the folders containing the native components of SQL Server Compact (x86 and/or amd64) - are not located in the same folder as the application executable.

Steps to Reproduce
1. Create an application that references System.Data.SqlServerCe and creates a new instance of SqlCeConnection;
2. Build the application and move just the executable file to a path containing the sharp symbol (ex.: "C:\Test\SqlCe#Bug");
3. Create a sub-folder to use for private deployment of SQL Server Compact (ex.: SqlCe -- full path: "C:\Test\SqlCe#Bug\SqlCe");
4. Copy the SQL Server Compact files and folders for private deployment from "%ProgramFiles%\Microsoft SQL Server Compact Edition\v4.0\Private" to the sub-folder created in step 3;
5. Create a file named %ExeName%.config in the path from step 2. %ExeName% represents the name of the executable file without extension;
6. Edit the .config file and change its content to:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
     <probing privatePath="SqlCe"/>
     <dependentAssembly>
        <assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845dcd8080cc91" />
        <bindingRedirect oldVersion="4.0.0.0" newVersion="4.0.0.1" />
     </dependentAssembly>
    </assemblyBinding>
</runtime>
</configuration>

Make sure that privatePath matches the sub-folder created in step 3. Save the .config file and launch the application. It will crash.

Posted by Microsoft on 3/5/2012 at 12:30 PM
Hello Steve,
Sorry for the late feedback. We looked at this and could not repro the issue. It will be good if you can provide more details. So for now, I am closing this item - please reopen if you can repro the issue.
Details on what we tried:

I could not repro this issue with SQLCE 3.5 sp2 32-bit and 64 bit setup and SQLCE 4.0 64 bit setup.

I created a SQLCE application in the folder path that contains '#' character. The application references sqlce mangaed dll and creates a db, opens a connections, inserts some records.

C:\Users\rusurla\Documents\Visual Studio 2010\Projects\C#\WindowsFormsApplication1\WindowsFormsApplication1\bin\x64\Debug\WindowsFormsApplication1.dll

--
Umachandar, SQL Programmability Team
Posted by Microsoft on 10/18/2011 at 12:28 AM
Thanks for logging the issue. We are analyzing the issue and will post back more information after the analysis is complete.

Regards,

Ambrish