2

Try:

  1. I created a new project in VS2012
  2. I installed via the NuGet package RavenDB Embedded -Pre
  3. I installed Ninject.MVC3
  4. Added a module for 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();
       }
    } 
    
  5. In my class "NinjectWebCommon" ...

    private static void RegisterServices(IKernel kernel)
    {
        kernel.Load(new RavenDBNinjectModule());
    } 
    

When running the application, the following url was generated ("http://localhost:1423")

Verify that the file "Raven.Studio.xap" was the root of my application

I tried accessing "http://localhost:8080" but the following screen is displayed: enter image description here

What am I doing wrong?

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
ridermansb
  • 10,779
  • 24
  • 115
  • 226

3 Answers3

0

You are setting the Url property, which means that you aren't running in embedded mode, but in server mode. Remove the Url property, and everything will work for you.

Ayende Rahien
  • 22,925
  • 1
  • 36
  • 41
  • I made the change yet. `var documentStore = new EmbeddableDocumentStore { DataDirectory="~/App_Data", UseEmbeddedHttpServer = true };` Actually was initially well, but as an attempt to put URL – ridermansb Jun 17 '12 at 11:14
0

I found the problem!

Since he had used IDocumentSession in no time, the ninject had not created the instance of IDocumentStore and thus not run the Initialize method

ridermansb
  • 10,779
  • 24
  • 115
  • 226
  • So how did you end up solving it? I have the same problem, the first request to my MVC app works and after that the raven studio takes over the app :) – Christian Sparre Feb 23 '13 at 15:16
0

As it turned out, the issue is that documentStore.Initialize never get called, because that no one did ask Ninject to resolve IDocumentStore.

Fitzchak Yitzchaki
  • 9,095
  • 12
  • 56
  • 96