我尝试以这种方式连接到我的MVC4应用程序中的嵌入式RavenDB
数据库:
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,我添加了#34;每个人都完全控制了#34;到数据库文件夹。
我能尝试什么?
答案 0 :(得分:1)
如果您在本地计算机上的IIS 7.5上托管您的页面,那么您获得的错误并不取决于您是否以管理员身份运行Visual Studio。 您需要以管理员身份运行应用程序,并且可以通过设置应用程序配置应用程序池的用户运行来执行此操作。
请转到 IIS管理器,点击您用于应用的应用程序池,点击'高级设置...',然后点击 “流程模型”将“身份”属性的值从默认的“ApplicationPoolIdentity”更改为自定义帐户 - 管理员。
一般情况下,我建议仅使用EmbeddableDocumentStore进行单元测试(当然在'InMemory'模式下运行)和应用程序 - 将RavenDB配置为作为Windows服务运行。