title: Activation error occured while trying to get instance of type
body: <p>I'm using Unity with an Asp.net MVC 3 app. Here is some code running in Application_Start...</p>
  
  <pre><code>        UnityContainer container = new UnityContainer();
  
          new UnityMappings(container).RegisterTypes();
  
          DependencyResolver.SetResolver(new UnityServiceLocator(container));
  </code></pre>
  
  <p>The controllers are registered with the UnityMappings instance like so...</p>
  
  <pre><code>IEnumerable&lt;Type&gt; controllerTypes = from t in Assembly.GetExecutingAssembly().GetTypes()
                                              where typeof (IController).IsAssignableFrom(t)
                                              select t;
  
      foreach (Type t in controllerTypes)
      {
          container.RegisterType(t);
      }
  </code></pre>
  
  <p>When I request a page I get the following errors... (The last one is specific to the view being requested.) </p>
  
  <blockquote>
    <p>Activation error occured while trying to get instance of type
    IControllerFactory, key ""</p>
    
    <p>Activation error occured while trying to get instance of type
    IControllerActivator, key ""</p>
    
    <p>Activation error occured while trying to get instance of type
    IViewPageActivator, key ""</p>
    
    <p>Activation error occured while trying to get instance of type
    ModelMetadataProvider, key ""</p>
  </blockquote>
  
  <p>And then strangely, I can click through all the exceptions and the page works absolutely fine! All the other dependencies are resolved just fine.</p>
  
  <p>Its not a Visual Studio issue because it does it in different instances from different machines. I've had to turn off breaking on all exceptions so that I can get anything done.</p>
  
  <p>Any ideas?</p>