0

I have MVC3 controllers in external assemblies using MVC contrib's portable areas but I'm having a problem getting Ninject to inject the constructor dependencies.

The controller is found but I get an exception of "No parameterless constructor defined for this object". I can see that ninject's controller factory is being called in the call stack but for external assemblies it just does not pass my database session.

Why could this be?

Max
  • 1,543
  • 2
  • 16
  • 31

2 Answers2

1

Probably you should update Ninject. RegisterAllControllersIn is from a version that is outdated since a long time.

Remo Gloor
  • 32,665
  • 4
  • 68
  • 98
0

You need to register the controllers in the other assemblies using Ninject's RegisterAllControllersIn method.

This is my implementation in the applicationstarted method of global.asax:

        foreach (var ass in BuildManager.GetReferencedAssemblies().Cast<Assembly>())
        {
            RegisterAllControllersIn(ass);
        }
Max
  • 1,543
  • 2
  • 16
  • 31