title: Unit testing ControllerFactory.CreateController : This method cannot be called during the application's pre-start initialization phase
body: <p>I have a test class . And inside this , i have  a private class </p>
  
  <pre><code>class ControllerProxy : MarshalByRefObject
  {    
     public IController CreateController()
     {
  
     }    
  }
  </code></pre>
  
  <p>Inside <code>CreateController()</code>, I have created a Mock RequestContext (<code>mockRequestContext</code>) and a Test Controller named "TestController" </p>
  
  <p>However, on calling </p>
  
  <pre><code>var controller = 
   controllerFactory.CreateController(mockRequestContext.Object, "TestController");
  </code></pre>
  
  <p>I am getting an <code>InvalidOperationException</code>:  </p>
  
  <blockquote>
    <p>"This method cannot be called during the application's pre-start
    initialization phase".</p>
  </blockquote>
  
  <p>Please help.</p>
  
  <p>Thanks in advance.</p>