2
votes

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?

3
Are you sure that documentStore.Initialize is actually get called? - Fitzchak Yitzchaki
If you post code snippets inside a bullet list of items, you need to indent the code by at least 8 spaces (not 4 as usual) - marc_s
documentStore.Initialize was not running! Thanks, @FitzchakYitzchaki you helped me find the solution. Write an answer, I'll approve it! - ridermansb
@RidermandeSousaBarbosa could you do an update to how you changed your code to make it work? - Fore

3 Answers

0
votes

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.

0
votes

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

0
votes

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