Kimpo
Kimpo

Reputation: 5836

SQLCE 4 - EF4.1 Internal error: Cannot open the shared memory region

Hi im trying to run my MVC 3 application running SQLCE 4 embedded and EF4.1

i have used the data access methods as described in this tutorial

This works perfectly locally(obviously), but when running it on my hosting i get the below error message. It is a shared hosting enviroment.

Is it an open connection that is the problem? Shouldn't it be handled by the unit of work class that is returning the dbcontext as a singleton throughout the whole application as mentioned in the tutorial?

Any tips on what this might be caused by would be appreciated

Internal error: Cannot open the shared memory region.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlServerCe.SqlCeException: Internal error: Cannot open the shared memory region.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

   [SqlCeException (0x80004005): Internal error: Cannot open the shared memory region.]
   System.Data.SqlServerCe.SqlCeConnection.ProcessResults(Int32 hr) +40
   System.Data.SqlServerCe.SqlCeConnection.Open(Boolean silent) +2542
   System.Data.SqlServerCe.SqlCeConnection.Open() +113
   System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +67

[EntityException: The underlying provider failed on Open.]
   System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +10975150
   System.Data.EntityClient.EntityConnection.Open() +142
   System.Data.Objects.ObjectContext.EnsureConnection() +97
   System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +66
   System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +47
   System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +220
   System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) +383
   System.Data.Entity.Internal.InternalContext.QueryForModelHash() +349
   System.Data.Entity.Internal.InternalContext.CompatibleWithModel(Boolean throwIfNoMetadata) +109
   System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) +373
   System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +64

[DataException: An exception occurred while initializing the database. See the InnerException for details.]
   System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +152
   System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +199
   System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +193
   System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +235
   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +38
   System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +89
   System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +21
   System.Data.Entity.Internal.Linq.InternalSet`1.Find(Object[] keyValues) +37
   Web.Infrastructure.DataAccess.Repository`1.GetByID(Object id) +131
   Web.Controllers.PagesController.Home() +154
   lambda_method(Closure , ControllerBase , Object[] ) +79
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +129
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +784922
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +784976
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +453
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371

Upvotes: 1

Views: 2976

Answers (1)

ErikEJ
ErikEJ

Reputation: 41749

This error indicates that the SQL Server Compact database file is located on a shared folder, not a local drive. That will not work.

Upvotes: 1

Related Questions