title: ASP.NET MVC, MVCContrib, Structuremap, getting it working as the controllerfactory?
body: <p>I'm trying to get structuremap to correctly create my controllers, I'm using DI to inject an INewsService into a NewsController and thats the only constructor I have.</p>
  
  <pre><code>public class NewsController : Controller
  {
      private readonly INewsService newsService;
  
      public NewsController(INewsService newsService)
      {
          this.newsService = newsService;
      }
  
      public ActionResult List()
      {
          var newsArticles = newsService.GetNews();
          return View(newsArticles);
      }
  }
  </code></pre>
  
  <p>and I'm using this code to start the app</p>
  
  <pre><code>public class Application : HttpApplication
  {
      protected void Application_Start()
      {
          RegisterIoC();
          RegisterViewEngine(ViewEngines.Engines);
          RegisterRoutes(RouteTable.Routes);
      }
  
      public static void RegisterIoC()
      {
          ObjectFactory.Initialize(config =&gt; {
              config.UseDefaultStructureMapConfigFile = false;
              config.AddRegistry&lt;PersistenceRegistry&gt;();
              config.AddRegistry&lt;DomainRegistry&gt;();
              config.AddRegistry&lt;ControllerRegistry&gt;();
          });
          DependencyResolver.InitializeWith(new StructureMapDependencyResolver());
          ControllerBuilder.Current.SetControllerFactory(typeof(IoCControllerFactory));            
      }
  }
  </code></pre>
  
  <p>But Structuremap doesn't seem to want to inject the INewsService and I get the error
  No parameterless constructor defined for this object.</p>
  
  <p>What have I missed?</p>