title: Value cannot be null.Parameter name: key
body: <p>Value cannot be null.Parameter name: key</p>
  
  <p>I have started to get this error since i ve implemented the StructureMapControllerFactory as my DefaultControllerFactory.</p>
  
  <p>Actually i copied the code from MVC Sample App StoreFront, but i couldn't figure out why this error keeps popping up. Even this error show up the application still runs.</p>
  
  <p>What might be the reason of this error ?</p>
  
  <p>Thanks for your time</p>
  
  <hr>
  
  <pre><code>System.ArgumentNullException was unhandled by user code
    Message="Value cannot be null.\r\nParameter name: key"
    Source="mscorlib"
    ParamName="key"
    StackTrace:
         at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
         at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
         at System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
         at StructureMap.Util.Cache`2.get_Item(KEY key)
         at StructureMap.BuildSession.CreateInstance(Type pluginType)
         at StructureMap.Container.GetInstance(Type pluginType)
         at StructureMap.ObjectFactory.GetInstance(Type pluginType)
         at Yacht.Web.Controllers.StructureMapControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) in D:\Documents\WebSites\JOBS\Yacht\Yacht.Web\Controllers\StructureMapControllerFactory.cs:line 16
         at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
         at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController&amp; controller, IControllerFactory&amp; factory)
         at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
         at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
         at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
         at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
         at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)
    InnerException: 
  </code></pre>
  
  <p>and this is the StructureMapControllerFactory class</p>
  
  <pre><code>public class StructureMapControllerFactory : DefaultControllerFactory
      {
          protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
          {
              return ObjectFactory.GetInstance(controllerType) as Controller;
          }
      }
  </code></pre>