我正在尝试运行运行SQLCE 4 embedded和EF4.1的MVC 3应用程序
我使用了this tutorial
中描述的数据访问方法这完全在本地(显然)工作,但在我的托管上运行时我得到以下错误消息。这是一个共享的托管环境。
这是一个开放的连接是问题吗?如本教程所述,整个应用程序中dbcontext作为单例返回的工作类是否应该处理?
有关这可能导致的任何提示将不胜感激
内部错误:无法打开共享内存区域。
描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.Data.SqlServerCe.SqlCeException:Internal 错误:无法打开共享内存区域。
来源错误:
在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。
堆栈追踪:
[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
答案 0 :(得分:1)
此错误表示SQL Server Compact数据库文件位于共享文件夹上,而不是本地驱动器上。那不行。