【发布时间】:2012-06-17 02:18:23
【问题描述】:
试试:
- 我在VS2012中新建了一个项目
- 我通过 NuGet 包安装RavenDB Embedded -Pre
- 我安装了Ninject.MVC3
-
为 ninject RavenDB 添加了一个模块:
Public class RavenDBNinjectModule : NinjectModule { public override void Load() { Bind<IDocumentStore>().ToMethod(context => { NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080); var documentStore = new EmbeddableDocumentStore { Url="http://localhost:8080/", DataDirectory="~/App_Data", UseEmbeddedHttpServer = true }; return documentStore.Initialize(); }).InSingletonScope(); Bind<IDocumentSession>().ToMethod(context => context.Kernel.Get<IDocumentStore>().OpenSession()).InRequestScope(); } } -
在我的班级“NinjectWebCommon”...
private static void RegisterServices(IKernel kernel) { kernel.Load(new RavenDBNinjectModule()); }
在运行应用程序时,生成了以下 url ("http://localhost:1423")
验证文件“Raven.Studio.xap”是我的应用程序的根目录
我尝试访问“http://localhost:8080”,但显示以下屏幕:
我做错了什么?
【问题讨论】:
-
你确定
documentStore.Initialize真的被调用了吗? -
如果您在项目符号列表中发布代码 sn-ps,您需要将代码缩进至少 8 个空格(而不是通常的 4 个)
-
documentStore.Initialize没有运行!谢谢,@FitzchakYitzchaki 你帮我找到了解决方案。写一个答案,我会批准! -
@RidermandeSousaBarbosa 您能否更新一下您如何更改代码以使其正常工作?
标签: asp.net-mvc-4 ravendb ravendb-studio