.net-4.0 - 错误 FileAccessDenied(JET_errFileAccessDenied,无法访问文件,文件被锁定或正在使用)

标签 .net-4.0 ravendb

我正在尝试将 Raven DB 部署到以集成模式运行 .Net 4 的站点(该站点以前用于托管 ASP.Net MVC 3 站点。

我的配置文件是这样的:

<appSettings>
    <add key="Raven/DataDir" value="~\App_Data"/>
    <add key="Raven/AnonymousAccess" value="All"/>
  <add key="Raven/Port" value="80"/>
</appSettings>
<system.webServer>
    <handlers>
        <add name="All" path="*" verb="*"
                type="Raven.Web.ForwardToRavenRespondersFactory, Raven.Web"/>
    </handlers>
</system.webServer>

但是,我得到的异常(exception)是:
**Error FileAccessDenied (JET_errFileAccessDenied, Cannot access file, the file is locked or in use)

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: Microsoft.Isam.Esent.Interop.EsentErrorException: Error FileAccessDenied (JET_errFileAccessDenied, Cannot access file, the file is locked or in use)

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: 


[EsentErrorException: Error FileAccessDenied (JET_errFileAccessDenied, Cannot access file, the file is locked or in use)]
   Microsoft.Isam.Esent.Interop.Api.Fail(Int32 err) in C:\Work\ravendb\SharedLibs\Sources\ManagedEsent-48322\EsentInterop\Api.cs:2279
   Microsoft.Isam.Esent.Interop.Api.JetInit(JET_INSTANCE& instance) in C:\Work\ravendb\SharedLibs\Sources\ManagedEsent-48322\EsentInterop\Api.cs:130
   Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:\Builds\raven\Raven.Storage.Esent\TransactionalStorage.cs:169

[InvalidOperationException: Could not open transactional storage: d:\IIS\domainfolder\ravendb\App_Data\Data]
   Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:\Builds\raven\Raven.Storage.Esent\TransactionalStorage.cs:182
   Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration) in c:\Builds\raven\Raven.Database\DocumentDatabase.cs:127
   Raven.Web.ForwardToRavenRespondersFactory..cctor() in c:\Builds\raven\Raven.Web\ForwardToRavenRespondersFactory.cs:31

[TypeInitializationException: The type initializer for 'Raven.Web.ForwardToRavenRespondersFactory' threw an exception.]
   Raven.Web.ForwardToRavenRespondersFactory..ctor() +0

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1136
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +23
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +60
   System.Web.Configuration.HandlerFactoryCache..ctor(String type) +46
   System.Web.HttpApplication.GetFactory(String type) +81
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184**

我已经联系了我的主机并确认我具有对 App_Data 的读/写访问权限,并且我自己也通过编写一些代码在此处创建文件来确认这一点。

我的主人暗示我的问题可能是由于我的数据存储的双重初始化——不管这意味着什么。

你们中的任何人都可以在这里指出我的解决方案吗?

更新 2011-05-18
我正在使用目前在 http://builds.hibernatingrhinos.com/download/2004 上可用的 RavenDB-Build-360 .我正在使用 http://ravendb.net/documentation/docs-deployment-iis 上的安装说明在 IIS 7.5 上运行它。但我没有使用自己的本地 IIS,而是将/Web-folder 的内容复制到我的主机。这意味着/bin 文件夹、web.config 和 SilverLight XAP 文件。所以我无法通过任何方式调试我的方式。

我没有注意到第一行(关于 WebDAV 模块),但我会尽快与我的主机核实。Raven DB 如何依赖于此?

最佳答案

我遇到了同样的问题 - 我的解决方案是将默认应用程序池身份从“ApplicationPoolIdentity”删除到管理员帐户(例如我自己用于测试目的)。
重新启动网站后,这才起作用。

关于.net-4.0 - 错误 FileAccessDenied(JET_errFileAccessDenied,无法访问文件,文件被锁定或正在使用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6028228/

相关文章:

c# - 在 RavenDB 中使用 SaveChangesAsync

RavenDB Changes API 从不触发

.net - 即时修改 app.config

security - 安全透明方法 X 尝试访问安全关键方法 Y 失败

.net - .NET 4.0 异步单元测试

c# - RavenDB 加载相关数据不起作用

c# - 如何加快 Raven DB 查询性能?

c# - Linq 读取缺少节点的 XML 文档

c# - 用 3 位数字分隔长号

asp.net-web-api - NewtonJson.NET 版本 4.0.8.0 的 RavenDb 客户端问题