views:

291

answers:

1

I have a SQL Server CE database that works fine in dev, but when installed on the client has an issue.

  • The SQL Server CE 3.5 dependencies are copied as part of the deployment.
  • The target machine is a clean Windows 7 32-bit Ultimate image.

The message for the exception in the event log is:

Message: Internal error: Cannot open the shared memory region. 
Stack Trace: at System.Data.SqlServerCe.SqlCeConnection.ProcessResults(Int32 hr) at
System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent) at
System.Data.SqlServerCe.SqlCeConnection.Open() at
System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user) at
System.Data.Linq.SqlClient.SqlProvider.Execute(
    Expression query, 
    QueryInfo queryInfo,
    IObjectReaderFactory factory, 
    Object[] parentArgs, 
    Object[] userArgs,
    ICompiledSubQuery[] subQueries, 
    Object lastResult) at
System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(
    Expression query, 
    QueryInfo[] queryInfos,
    IObjectReaderFactory factory, 
    Object[] userArguments, 
    ICompiledSubQuery[]
    subQueries) at
System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(
    Expression query) at
System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at 
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at
System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at
Application specific stuff here

It looks like this is SSCE_M_CANTOPENSHAREDMEMORY and the site says there isn't a connection string value to change this and that these issues are typically not resolvable by the end developers.

Has anyone run into this, and if so were you able to resolve this issue?

+1  A: 

You're right that the CE runtime has to be installed. And if you're using VS2010, you have to make sure that you install SP2 of the CE runtimes.

Even with that installed, I've run into this. In my case, I had a SQL Server CE instance acting as a local cache for a database using ADO.NET Synchronization Services. Is this your scenario?

I found that on test machines I got this error:

  • If the platform was Vista or Windows 7; and
  • If the SQL Server CE database was installed with the application to
    reside in a protected directory, such as C:\Program Files or C:\Program
    Files (x86); and
  • If the program was run using standard user credentials (i.e. not escalated to Administrator)

Workarounds for the condition included:

  • Running the application "as Administrator"; or
  • Configuring the application manifest to require Administrator credentials; or
  • Refactoring the application so that the .sdf file was located in an unprotected directory, such as C:\ProgramData[some subdirectory name] and modifying the connection string to point to that area; or
  • Relocating the entire application directory in a user space. For instance, in "Documents" or some similar space with full file access rights to the EXE and the .SDF file

    Obviously, each of those options has its disadvantages.

Rob Perkins