title: Simple Injector with Web API 2. PreApplicationStartMethod doesn't run
body: <p>I am following Onion Architecture for my Web API and AngularJS Project. In the Infrastructure.DependencyResolution part, I am using Simple Injector. Here is my code:</p>
  
  <pre><code>[assembly: PreApplicationStartMethod(typeof(IocConfig), "RegisterDependencies")]
  namespace Infrastructure.DependencyResolution
  {
      public class IocConfig
      {
           private static Container _container;
  
           public static void RegisterDependencies()
           {
                _container = new Container();
  
                _container.Verify();
  
                _container.RegisterWebApiRequest&lt;IEntitiesContext&gt;(() =&gt;
                {
                     return new MyContext();
                });
  
                _container.RegisterWebApiRequest&lt;IUserRepository, UserRepository&gt;();
                _container.RegisterWebApiRequest&lt;IAccountService, AccountService&gt;();
                _container.RegisterWebApiRequest&lt;IUnitOfWork, UnitOfWork&gt;();
  
           }
      }
  }
  </code></pre>
  
  <p>Now If I try to put url to go to my account controller, I am getting this error:</p>
  
  <blockquote>
    <p>An error occurred when trying to create a controller of type
    'AccountController'. Make sure that the controller has a parameterless
    public constructor.</p>
  </blockquote>
  
  <p>I searched and found out that Simple Injector has some different code for Web Api as suggested by their <a href="http://simpleinjector.readthedocs.org/en/latest/webapiintegration.html" rel="nofollow">site</a> Like:</p>
  
  <pre><code>// This is an extension method from the integration package.
  container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
  </code></pre>
  
  <p>I copied that as well but it did not accept GlobalConfiguration.Configuration, I guess because I am using it in a library project.</p>
  
  <p>When I set a break point in the <code>RegisterDependencies</code> method, Visual Studio doesn't stop at the break point.</p>
  
  <p>Can someone show me the way where to go?</p>