title: How to configure dependency injection with ASP.NET MVC 3 RTM
body: <p>I am upgrading a web app from ASP.NET 3 Preview 1 to the RTM and I am confused by the updated approach to dependency injection. I am using StructureMap for this but that's not really relevant to my question. Previously all I needed to do was as follows:</p>
  
  <pre><code>x.For&lt;IControllerFactory&gt;().Use&lt;DefaultControllerFactory&gt;();
  x.For&lt;IServiceLocator&gt;().Use(MvcServiceLocator.Current);
  </code></pre>
  
  <p>Now it seems like I need to provide implementations of IControllerActivator, IViewPageActivator and ModelMetadataProvider because otherwise I get an error from StructureMap because MVC tries to locate them using the dependency resolver. From a look at the MVC source there do not seem to be public default implementations. Am I missing something in setting these up? Surely these should be configured by convention?</p>
  
  <p>Examples of what needs configuring and how with StructureMap would be appreciated. For reference I am currently using the following ugly kludge which forces MVC to use its internal defaults:</p>
  
  <pre><code>x.For&lt;IControllerFactory&gt;().Use&lt;DefaultControllerFactory&gt;();
  x.For&lt;IDependencyResolver&gt;().Use(() =&gt; DependencyResolver.Current);                
  x.For&lt;IControllerActivator&gt;().Use(() =&gt; null);
  x.For&lt;IViewPageActivator&gt;().Use(() =&gt; null);
  x.For&lt;ModelMetadataProvider&gt;().Use(ModelMetadataProviders.Current);
  </code></pre>
  
  <p>EDIT: Just to be clear I have a working StructureMap implementation of the Dependency Resolver - the issue is why MVC is complaining about all these interfaces not being configured in the container.</p>