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

asp.net-mvc – RavenDB部署问题

发布时间:2020-12-15 19:32:40 所属栏目:asp.Net 来源:网络整理
导读:我已经开发了一个ASP.Net MVC 3应用程序,它使用RavenDB Embedded作为数据的集成后台存储,我使用 this教程作为开始使用RavenDB Embedded创建MVC应用程序的基础.我已经能够在我的开发PC上运行得很好,但是当它运行在运行IIS6的Windows Server 2003 Web服务器上
我已经开发了一个ASP.Net MVC 3应用程序,它使用RavenDB Embedded作为数据的集成后台存储,我使用 this教程作为开始使用RavenDB Embedded创建MVC应用程序的基础.我已经能够在我的开发PC上运行得很好,但是当它运行在运行IIS6的Windows Server 2003 Web服务器上的时候,它会出现以下错误:

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.EsentFileAccessDeniedException: 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:

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

[InvalidOperationException: Could not open transactional storage:
C:inetpubwwwrootMyAppApp_DataDatabaseRavenDBData]
Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator
uuidGenerator) in
c:BuildsRavenDB-StableRaven.Storage.EsentTransactionalStorage.cs:222
Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration
configuration) in
c:BuildsRavenDB-StableRaven.DatabaseDocumentDatabase.cs:185
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:496
MyApp.CompositionRoot.CreateControllerFactory() in
…MyAppCompositionRoot.cs:36 MyApp.CompositionRoot..ctor() in
..MyAppCompositionRoot.cs:17
MyApp.MvcApplication.Application_Start() in …MyAppGlobal.asax.cs:38

[HttpException (0x80004005): Could not open transactional storage:
C:inetpubwwwrootMyAppApp_DataDatabaseRavenDBData]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context,HttpApplication app) +3985477
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext,HttpContext context,MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers,IntPtr appContext,HttpContext context) +325
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext,HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +375

[HttpException (0x80004005): Could not open transactional storage:
C:inetpubwwwrootMyAppApp_DataDatabaseRavenDBData]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr,HttpContext context) +4782309

引用的CompositionRoot.cs类中的错误的来源是可嵌入文档存储的初始化.

private static IControllerFactory CreateControllerFactory()
{
    var cacheRepository = new EmbeddableDocumentStore();
    cacheRepository.ConnectionStringName = "RavenDB";

    #if DEBUG
        cacheRepository.UseEmbeddedHttpServer = true;
    #endif

    Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);
    cacheRepository.Initialize(); //Source of Error
    var controllerFactory = new TDRControllerFactory(cacheRepository);
    return controllerFactory;
}

为什么这只发生在Web服务器上,而不是在我的开发PC上?我不知道究竟是什么原因.任何帮助是赞赏.

解决方法

这原来是一个权限问题,我给了IIS_IUSRS组修改和写入我的应用程序的文件夹的根目录,并给予它正确初始化数据库所需的权限.根目录中可能有一个特定的文件夹,它需要修改/写入访问权限(在我的情况下,可能是App_Data文件夹,因为我正在实例化我的RavenDB实例).我必须测试,因为我不希望任何用户对整个应用程序文件夹具有修改/写入权限.

(编辑:李大同)

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

    推荐文章
      热点阅读