Richmond 2003
Richmond 2003

Reputation: 21

autofac mvc areas in separate projects

I've separated my MVC4 app into areas BUT using separate projects In each module project (area) I have a module to register the controllers

protected override void Load(ContainerBuilder builder)
        {
            var assembly = Assembly.GetExecutingAssembly();

            builder.RegisterControllers(assembly);
            builder.RegisterModelBinders(assembly);
            builder.RegisterModelBinderProvider();
            builder.RegisterFilterProvider();
        }

I have a controller

public class SomeController : Controller {
        public SomeController (IDependency dependency){}
 }

and in the main project global I have this:

 builder.RegisterAssemblyModules();

Then when I run this I get this error:

No parameterless constructor provided. 

It seems that the registration did not happen. The areas projects are NOT referenced in the main project

How can I register them?

Upvotes: 2

Views: 1050

Answers (1)

Travis Illig
Travis Illig

Reputation: 23934

Most likely (without seeing how your project is set up and being initialized, other than the tiny code snippet provided in the question) this is a problem with ASP.NET being unable to properly locate the type to resolve.

Make sure you've got your plugin assemblies registered with the BuildManager.

This blog article should help you get where you need to go.

Upvotes: 2

Related Questions