加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – RavenDb,无法访问文件,文件被锁定或正在使用中

发布时间:2020-12-16 10:01:56 所属栏目:asp.Net 来源:网络整理
导读:这是例外,现在让我的生活变得痛苦.不知道什么是改变但数据库在MVC3站点的App_Data文件夹中.该网站作为默认网站在IIS 7.5中托管. 任何解决方案的提示都会受到欢迎. 编辑..问题可能或多或少与我的控制器代码有关,在抛出异常后没有清理,因此不会在文档会话上调
这是例外,现在让我的生活变得痛苦.不知道什么是改变但数据库在MVC3站点的App_Data文件夹中.该网站作为默认网站在IIS 7.5中托管.

任何解决方案的提示都会受到欢迎.

编辑..问题可能或多或少与我的控制器代码有关,在抛出异常后没有清理,因此不会在文档会话上调用dispose

Line 30:             instance = new EmbeddableDocumentStore { ConnectionStringName = "RavenDB" };
Line 31:             instance.Conventions.IdentityPartsSeparator = "-";
Line 32:             instance.Initialize();

[EsentFileAccessDeniedException: Cannot access file,the file is locked or in use]
   Microsoft.Isam.Esent.Interop.Api.Check(Int32 err) in C:WorkravendbSharedLibsSourcesmanagedesent-61618EsentInteropApi.cs:2739
   Microsoft.Isam.Esent.Interop.Api.JetInit(JET_INSTANCE& instance) in C:WorkravendbSharedLibsSourcesmanagedesent-61618EsentInteropApi.cs:131
   Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:BuildsRavenDB-StableRaven.Storage.EsentTransactionalStorage.cs:207

[InvalidOperationException: Could not open transactional storage: C:codeBECom.BuyEfficientCom.BuyEfficient.WebApp_DataravendataData]
   Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:BuildsRavenDB-StableRaven.Storage.EsentTransactionalStorage.cs:220
   Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration) in c:BuildsRavenDB-StableRaven.DatabaseDocumentDatabase.cs:156
   Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal() in c:BuildsRavenDB-StableRaven.Client.EmbeddedEmbeddableDocumentStore.cs:143
   Raven.Client.Document.DocumentStore.Initialize() in c:BuildsRavenDB-StableRaven.Client.LightweightDocumentDocumentStore.cs:483
   Com.BuyEfficient.Web.Infrastructure.DataDocumentStore.Initialize() in C:codeBECom.BuyEfficientCom.BuyEfficient.WebInfrastructureDataDocumentStore.cs:32
   Com.BuyEfficient.Web.App_Start.Services.PreStart() in C:codeBECom.BuyEfficientCom.BuyEfficient.WebApp_StartServices.cs:25

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method,Object target,Object[] arguments,SignatureStruct& sig,MethodAttributes methodAttributes,RuntimeType typeOwner) +0
   System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method,Signature sig,RuntimeType typeOwner) +72
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] parameters,CultureInfo culture,Boolean skipVisibilityChecks) +335
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj,CultureInfo culture) +28
   System.Reflection.MethodBase.Invoke(Object obj,Object[] parameters) +19
   WebActivator.BaseActivationMethodAttribute.InvokeMethod() +221
   WebActivator.ActivationManager.RunActivationMethods() +491
   WebActivator.ActivationManager.RunPreStartMethods() +28
   WebActivator.ActivationManager.Run() +55

[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +423
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException) +677

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090044
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context) +256

解决方法

Spaten,您需要确保正确处理DocumentStore和DocumentSession生命周期管理.您应该在应用程序启动时将DocumentStore创建为单例,并且应该在开始和结束请求上打开并配置会话.我建议为OnBeginRequest和OnEndRequest编写自己的处理程序.

请查看官方示例应用程序RaccoonBlog,了解其工作原理.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读