Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomapper asking for MVC3 reference in a MVC4 app with MvcExtensions
    primarykey
    data
    text
    <p>I am using <code>ASP.NET MVC 4 RC</code> and the latest version of <code>MvcExtensions</code> and <code>MvcExtensions.Autofac</code>.</p> <p>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.</p> <p>I replaced the Global.asax.cs file to look like this:</p> <pre><code>public class MvcApplication : AutofacMvcApplication { public MvcApplication() { Bootstrapper.BootstrapperTasks .Include&lt;RegisterAreas&gt;() .Include&lt;RegisterControllers&gt;() .Include&lt;RegisterRoutesBootstrapper&gt;() .Include&lt;AutoMapperBootstrapper&gt;() .Include&lt;FluentValidationBootstrapper&gt;(); } protected override void OnStart() { FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); base.OnStart(); } } </code></pre> <p><code>RegisterRoutesBootstrapper</code>, <code>AutoMapperBootstrapper</code> and <code>FluentValidationBootstrapper</code> are my custom bootstrapper classes. The code for AutoMapperBootstrapper looks like this:</p> <pre><code>public class AutoMapperBootstrapper : BootstrapperTask { public override TaskContinuation Execute() { const string mappingNamespace = "MyProject.DomainModel.Mappings"; IEnumerable&lt;Type&gt; mappingTypes = typeof(IEntity).Assembly .GetTypes() .Where( type =&gt; type.IsPublic &amp;&amp; type.IsClass &amp;&amp; !type.IsAbstract &amp;&amp; !type.IsGenericType &amp;&amp; type.Namespace == mappingNamespace); mappingTypes.ForEach(t =&gt; Activator.CreateInstance(t)); return TaskContinuation.Continue; } } </code></pre> <p>It underlined IEnumerable in blue with the error:</p> <pre><code>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'. </code></pre> <p>Ok so when I compiled my project it is looking for an ASP.NET MVC 3 reference:</p> <pre><code>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. </code></pre> <p>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.</p> <p>Any ideas why it is asking for an the MVC reference?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload