title: Visual Studio's IIS Express: Could not load file or assembly
body: <p>I got myself into some problems, when trying to load a solution (GMap.NET), which I had some problems to build. Not sure that matters now though.</p>
  
  <p>I am developing a small system in Visual Studio 2015, which also has a MVC project. When I launch the basic website - more or less just the initial MVC 5 template - through Visual Studio 2015 - that uses IIS Express - I get this error message:</p>
  
  <blockquote>
    <p>Could not load file or assembly '<strong>System.Web.WebPages.Deployment</strong>, Version=<strong>1.0.0.0</strong>, 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)
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
    
    <p>Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.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)
    [There is more]</p>
  </blockquote>
  
  <p>I don't know where the version 1.0.0.0 is coming from! The version I am referencing is 3.0.0.0...</p>
  
  <p>Also - If I publish to my local IIS - it works! 
  I have opened the same solution on two other computers - and there I can launch it from Visual Studio!
  That means - the problem is on my computer - not in my solution... I am pretty sure.</p>
  
  <p>I suspect that something is messed up on the machine. Maybe in GAC, or some config, but I don't know where... I am thinking on files like this (not that I know much about them):</p>
  
  <ul>
  <li>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config</li>
  <li>C:\Users\\Documents\IISExpress\config\aspnet.config</li>
  <li>???</li>
  </ul>
  
  <p>For GAC it doesn't seem that there is the System.Web.WebPages.Deployment.dll. And as it works on the "real" IIS, it must also be ok there.</p>
  
  <p>I also tried to delete all files in 'C:/Users/#user#/AppData/Local/Temp/Temporary ASP.NET Files/vs/'</p>
  
  <p>That should narrow it down to this:
   - The problem must have something to do with Visual Studio and/or IIS Express - and/or some configuration file.
   - not a problem with the references in the solution. (I used nuget to install MVC)</p>
  
  <p>Fx. in this file, there is an entry with System.Web.WebPages.Deployment version 1.0.0.0:
  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config:</p>
  
  <pre><code>&lt;compilation&gt;
    &lt;assemblies&gt;
  &lt;!-- &lt;remove assembly="System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt;
          &lt;add assembly="System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt; --&gt;`
  ...
  &lt;/compilation&gt;
  </code></pre>
  
  <p>But I already tried to uncomment it. No difference... </p>
  
  <p>So if anybody can give me a hint where to look... files to compare or something, I will appreciate it a lot!</p>
  
  <p><strong>Here is the full message that I get</strong>:</p>
  
  <blockquote>
    <p>Server Error in '/' Application.</p>
    
    <p>Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.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) 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
    
    <p>Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.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>
    
    <p>Source Error: </p>
    
    <p>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. </p>
    
    <p>Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.</p>
    
    <p>Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
    Running under executable  <strong>C:\Program Files (x86)\IIS Express\iisexpress.exe</strong>
    --- A detailed error log follows. </p>
    
    <p>=== Pre-bind state information ===
    LOG: DisplayName = System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
     (Fully-specified)
    LOG: Appbase = file:///C:/Users/#user#/Source/Workspaces/MySystem/MySystem/Frontend.Web/
    LOG: Initial PrivatePath = C:\Users#user#\Source\Workspaces\MySystem\MySystem\Frontend.Web\bin</p>
    
    <h1>Calling assembly : (Unknown).</h1>
    
    <p>LOG: <strong>This bind starts in default load context</strong>.
    LOG: Using application configuration file: C:\Users#user#\Source\Workspaces\MySystem\MySystem\Frontend.Web**web.config**
    LOG: <strong>Using host</strong> configuration file: C:\Users#user#\Documents\IISExpress\config\aspnet.config
    LOG: <strong>Using machine</strong> configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: <strong>Post-policy reference</strong>: System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    LOG: Attempting download of new URL file:///C:/Users/#user#/AppData/Local/Temp/<strong>Temporary ASP.NET Files/vs/0c78498f/ece65cb2/System.Web.WebPages.Deployment.DLL</strong>.
    LOG: Attempting download of new URL file:///C:/Users/#user#/AppData/Local/Temp/Temporary ASP.NET Files/vs/0c78498f/ece65cb2/System.Web.WebPages.Deployment/System.Web.WebPages.Deployment.DLL.
    LOG: Attempting download of new URL file:///C:/Users/#user#/Source/Workspaces/MySystem/MySystem/Frontend.Web/bin/System.Web.WebPages.Deployment.DLL.
    <strong>WRN: Comparing the assembly name resulted in the mismatch: Major Version
    ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.</strong></p>
    
    <p>Stack Trace: </p>
    
    <p>[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.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)]
       System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
       System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
       System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
       System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
       System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection) +21
       System.Reflection.Assembly.Load(String assemblyString) +28
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38</p>
    
    <p>[ConfigurationErrorsException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.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)]
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +738
       System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +57
     System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
      System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +92
       System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean&amp; isRefAssemblyLoaded) +290
       System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +531</p>
    
    <p>[HttpException (0x80004005): Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.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)]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9963380
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254</p>
    
    <p>Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0</p>
  </blockquote>