gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 01:20:03 25 4
gpt4 key购买 nike

这是一个异常(exception),现在完全让我的生活很痛苦.. 不知道发生了什么变化,但数据库位于 MVC3 站点的 App_Data 文件夹中。该网站托管在 IIS 7.5 中,作为默认网站。

欢迎任何解决问题的提示。

编辑 .. 问题可能或多或少与我的 Controller 代码在抛出异常后没有清理有关,因此没有在文档 session 上调用 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:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:2739
Microsoft.Isam.Esent.Interop.Api.JetInit(JET_INSTANCE& instance) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:131
Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:207

[InvalidOperationException: Could not open transactional storage: C:\code\BE\Com.BuyEfficient\Com.BuyEfficient.Web\App_Data\ravendata\Data]
Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:220
Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration) in c:\Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:156
Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal() in c:\Builds\RavenDB-Stable\Raven.Client.Embedded\EmbeddableDocumentStore.cs:143
Raven.Client.Document.DocumentStore.Initialize() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\DocumentStore.cs:483
Com.BuyEfficient.Web.Infrastructure.DataDocumentStore.Initialize() in C:\code\BE\Com.BuyEfficient\Com.BuyEfficient.Web\Infrastructure\DataDocumentStore.cs:32
Com.BuyEfficient.Web.App_Start.Services.PreStart() in C:\code\BE\Com.BuyEfficient\Com.BuyEfficient.Web\App_Start\Services.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, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, 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, BindingFlags invokeAttr, Binder binder, Object[] parameters, 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 创建为单例,并且应该在开始和结束请求时打开和处理 session 。我建议为 OnBeginRequest 和 OnEndRequest 编写自己的处理程序。

请看官方示例应用,RaccoonBlog ,看看这是如何工作的。

关于asp.net-mvc-3 - RavenDb,无法访问文件,文件被锁定或正在使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9933878/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com