title: asp mvc 2 structure map not working when deployed
body: <p>I'm using structure map in my asp mvc site, which i've just tried to deploy onto II6 for the first time.</p>
  
  <p>The basic dependency structure is very typical:</p>
  
  <pre><code>    public ControlMController(IControlMService controlMservice)
      {
          this._controlMservice = controlMservice;
      }
  
      ...
  
      public ControlMService(IControlMRepository repo)
      {
          this._repo = repo;
      }
  
      ...
  
      public SQLControlMRepository (CTRLMDataContext dataContext)
      {
          _db = dataContext;
      }
  </code></pre>
  
  <p>My structureMap Registry is like this</p>
  
  <pre><code>        For&lt;IControlMService&gt;().Use&lt;ControlMService&gt;();
          For&lt;IControlMRepository&gt;().Use&lt;SQLControlMRepository&gt;();
          //For&lt;IControlMRepository&gt;().Use&lt;TestControlMRepository&gt;();
          SelectConstructor&lt;CTRLMDataContext&gt;(() =&gt; new CTRLMDataContext());
          For&lt;CTRLMDataContext&gt;().LifecycleIs(new HybridLifecycle()).Use&lt;CTRLMDataContext&gt;();
  </code></pre>
  
  <p>My Controller Factory looks like this:</p>
  
  <pre><code>public class ControllerFactory : DefaultControllerFactory 
  {
      protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
      {
          try
          {
              if (controllerType == null) return base.GetControllerInstance(requestContext,controllerType);
              return ObjectFactory.GetInstance(controllerType) as IController;
          }
          catch
          {
              System.Diagnostics.Debug.WriteLine(ObjectFactory.WhatDoIHave());
              return null;
          }
      }
  }
  </code></pre>
  
  <p>This works 100% on the development server, but it does not work on when i deployed to IIS 6 on a  server.</p>
  
  <p>The ControlMController which has all of the dependenies returns the following exception:</p>
  
  <pre><code>[InvalidOperationException: The IControllerFactory 'SupportTool.web.Controllers.ControllerFactory' did not return a controller for the name 'ControlM'.]
     System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +304
     System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +54
     System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75
  </code></pre>
  
  <p>All of the the other controllers which have 0 dependencies work fine on the server, so the installation of structuremap must be working a little, just not entirely :/</p>