title: Simple Injector Dependency Resolution Error - Could not load file or assembly System.Web.Http
body: <p>I am following onion architecture and using <code>simple injector</code> in the DependencyResolution Project. Here is my architecture:</p>
  
  <pre><code>1-Core
       - Domain Classes
       - Repository Interfaces
       - Service Interfaces
  2-Infrastructure
       - Data
       - Dependency Resolution
       - Repository Interfaces Implementation
       - Service Interfaces Implementation
  3-WebApi
       - Web Api Project
  4-WebClient
       - My AngularJs App
  5-Test
       - Test Project
  </code></pre>
  
  <p><strong>StartUp.cs</strong></p>
  
  <pre><code>public partial class Startup
      {
          public void Configuration(IAppBuilder app)
          {
              // Here I am getting error at runtime.
              SimpleInjectorInitializer.Initialize(app);
              ConfigureAuth(app);
          }
      }
  </code></pre>
  
  <p><strong>SimpleInjectorInitializer.Initialize</strong></p>
  
  <pre><code>public static Container Initialize(IAppBuilder app)
          {
              var container = GetInitializeContainer(app);
  
              // This is an extension method from the integration package.
              container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
  
              container.Verify();
  
              GlobalConfiguration.Configuration.DependencyResolver =
                  new SimpleInjectorWebApiDependencyResolver(container);
  
              return container;
          }
  </code></pre>
  
  <p>Here I added reference to <code>System.Web, System.Web.Http, System.Web.Http.Host</code> taken from WebApi project. </p>
  
  <p>I put the path of the output of my DependencyResolution project to WebApi bin and set the value of owinstart in <code>web.config</code>.</p>
  
  <p>Here is the error I am getting:</p>
  
  <blockquote>
    <p>An exception of type 'System.IO.FileLoadException' occurred in
    Infrastructure.DependencyResolution.dll but was not handled in user
    code</p>
    
    <p>Additional information: Could not load file or assembly
    'System.Web.Http, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The
    located assembly's manifest definition does not match the assembly
    reference. (Exception from HRESULT: 0x80131040)</p>
  </blockquote>
  
  <p><strong>Edit:</strong></p>
  
  <p>Here is App.Config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
    &lt;/configSections&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
  &lt;/configuration&gt;
  </code></pre>