Ninject in a Classlibrary and ASP.NET MVC

Asked

Viewed 14 times

1

To understand, I’m going to set the stage. The application uses ninject with repositories and services, but some models have navigation properties, all in the same project

In MVC there is the object Dependencyresolver.Current.Getservice pointing to the ninject module (configured for this).

However, we need to migrate all this logic to another project, for reuse, but also minimize code refactoring.

In a library class, how do I use ninject ?

The main project will be an MVC with a library class. How I use this Dependencyresolver in the library?

I can create the Ninject kernel and store it in a static variable?

private static Ninject.StandardKernel _kernel = null;

static DependencyResolver()
{
    _kernel = new Ninject.StandardKernel();
    _kernel.Load(AppDomain.CurrentDomain.GetAssemblies());

}

Would doing so affect the functioning of the ninject ? What is the best method to do this?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.