1

我正在尝试以RavenDB这种方式连接到我的 MVC4 应用程序中的嵌入式数据库:

NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);
documentStore = new EmbeddableDocumentStore
{
       ConnectionStringName = ConnectionStringName,
       UseEmbeddedHttpServer = true
};

documentStore.Initialize();

如果我删除UseEmbeddedHttpServer = true选项,它会起作用,我通常可以保存并从数据库中读取!但是,如果指定它通过 Management Studio (localhost:8080) 访问,我会收到一个Access Denied错误 documentStore.Initialize()

这是完整的堆栈:

[HttpListenerException (0x5): Accesso negato]
   System.Net.HttpListener.AddAllPrefixes() +335
   System.Net.HttpListener.Start() +680
   Raven.Database.Server.HttpServer.StartListening() in c:\Builds\RavenDB-Unstable-v2.0\Raven.Database\Server\HttpServer.cs:336
   Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal() in c:\Builds\RavenDB-Unstable-v2.0\Raven.Client.Embedded\EmbeddableDocumentStore.cs:210
   Raven.Client.Document.DocumentStore.Initialize() in c:\Builds\RavenDB-Unstable-v2.0\Raven.Client.Lightweight\Document\DocumentStore.cs:424
   RavenDbTest.Repository.DocumentStoreHolder.get_DocumentStore() in c:\Sviluppo\RavenDbTest\RavenDbTest\RavenDbTest\Repository\DocumentStoreHolder.cs:39
   RavenDbTest.Controllers.RavenController.OnActionExecuting(ActionExecutingContext filterContext) in c:\Sviluppo\RavenDbTest\RavenDbTest\RavenDbTest\Controllers\RavenController.cs:23
   System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeActionMethodFilterAsynchronously(IActionFilter filter, ActionExecutingContext preContext, Func`1 nextInChain) +145
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__31(AsyncCallback asyncCallback, Object asyncState) +266
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +202
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag) +112
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__1e(AsyncCallback asyncCallback, Object asyncState) +838303
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +166
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag) +27
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__17(AsyncCallback asyncCallback, Object asyncState) +50
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +166
   System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +825393
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +166
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag) +27
   System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +401
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__2(AsyncCallback asyncCallback, Object asyncState) +785498
   System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +146
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +166
   System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag) +27
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +343
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12551795
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

我以管理员身份运行 IIS 7.5、VS2012,并将“所有人完全控制”添加到数据库文件夹。

我可以尝试什么?

4

1 回答 1

1

如果您在本地计算机上的 IIS 7.5 上托管您的页面,那么您收到的错误并不取决于您是否以管理员身份运行 Visual Studio。您需要以管理员身份运行您的应用程序,您可以通过设置运行您的应用程序配置的应用程序池的用户来实现。

因此,转到IIS 管理器,单击您用于应用程序的应用程序池,单击“高级设置...”,然后在“进程模型”下将“身份”属性的值从默认的“应用程序池身份”更改为自定义帐户- 您的情况下的管理员

一般来说,我建议仅将 EmbeddableDocumentStore 用于单元测试(当然在“InMemory”模式下运行)和应用程序 - 将 RavenDB 配置为作为 Windows 服务运行。

于 2013-01-20T09:55:18.570 回答