I am using ASP.NET MVC 4 RC
and the latest version of MvcExtensions
and MvcExtensions.Autofac
.
I don't know if MVC 4 works differently to MVC 3? The code below is how I used it in my MVC 3 application. I have just copied and pasted it into my MVC 4 app.
I replaced the Global.asax.cs file to look like this:
public class MvcApplication : AutofacMvcApplication
{
public MvcApplication()
{
Bootstrapper.BootstrapperTasks
.Include<RegisterAreas>()
.Include<RegisterControllers>()
.Include<RegisterRoutesBootstrapper>()
.Include<AutoMapperBootstrapper>()
.Include<FluentValidationBootstrapper>();
}
protected override void OnStart()
{
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
base.OnStart();
}
}
RegisterRoutesBootstrapper
, AutoMapperBootstrapper
and FluentValidationBootstrapper
are my custom bootstrapper classes. The code for AutoMapperBootstrapper looks like this:
public class AutoMapperBootstrapper : BootstrapperTask {
public override TaskContinuation Execute()
{
const string mappingNamespace = "MyProject.DomainModel.Mappings";
IEnumerable<Type> mappingTypes = typeof(IEntity).Assembly
.GetTypes()
.Where(
type =>
type.IsPublic &&
type.IsClass &&
!type.IsAbstract &&
!type.IsGenericType &&
type.Namespace == mappingNamespace);
mappingTypes.ForEach(t => Activator.CreateInstance(t));
return TaskContinuation.Continue;
} }
It underlined IEnumerable in blue with the error:
The type 'System.Web.Mvc.Controller' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Ok so when I compiled my project it is looking for an ASP.NET MVC 3 reference:
The type 'System.Web.Mvc.IViewPageActivator' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. There about 10 such errors relating to the AutoMapperBootstrapper.cs file.
I didn't bother with this reference and added the MVC 4 reference. I thought that this would have solved my areas issue but it did not.
Any ideas why it is asking for an the MVC reference?