Help with Ninject in mvc3!

Here is my problem. My application has several projects.

  • WEB (controllers and views)
  • Services
  • Data (edmx and repositories)
  • Entities (POCO)
  • Test

So in my web project I have a ninject configuration

[assembly: WebActivator.PreApplicationStartMethod(typeof(PublicPanama.AppStart_NinjectMVC3), "Start")]

    namespace Web{
        public static class AppStart_NinjectMVC3 {
            public static void RegisterServices(IKernel kernel) {
                //kernel.Bind<IThingRepository>().To<SqlThingRepository>();
                kernel.Bind<IContributorService>().To<ContributorService>();
            }

            public static void Start() {
                // Create Ninject DI Kernel 
                IKernel kernel = new StandardKernel();

                // Register services with our Ninject DI Container
                RegisterServices(kernel);

                // Tell ASP.NET MVC 3 to use our Ninject DI Container 
                DependencyResolver.SetResolver(new NinjectServiceLocator(kernel));
            }
        }
    }

The problem is that I also want to add

kernel.Bind<IRepository>().To<Repository>();

But my web project does not have a link to the Data project .. and just adding a link for this does not seem right.

What am I missing? please, help!

+1
source share
1 answer

http://www.planetgeek.ch/2010/11/13/official-ninject-mvc-extension-gets-support-for-mvc3/

And don't forget to read the @Brad Wilson blog series (ref'd in article)

+1
source

Source: https://habr.com/ru/post/1790371/


All Articles