title: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0
body: <p>I just upgraded packages in an MVC 3 project (ASP.net 4), and now I am getting the following error message when accessing a page in that project:</p>
  
  <blockquote>
    <h2>Server Error in '/MyApplication' Application.</h2>
    
    <p>Could not load file or assembly 'System.Web.WebPages.Razor,
    Version=2.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.Razor, Version=2.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.Razor,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
    could not be loaded.</p>
    
    <p>=== Pre-bind state information === LOG: User = IIS APPPOOL\ASP.NET v4.0 LOG: DisplayName = System.Web.WebPages.Razor, Version=2.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35  (Fully-specified)
    LOG: Appbase = file:///C:/.../ LOG: Initial PrivatePath = C:...\bin
    Calling assembly : Microsoft.Web.Helpers, Version=2.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35.
    === LOG: This bind starts in default load context. LOG: Using application configuration file: C:...\web.config LOG: Using host
    configuration file:
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config LOG:
    Using machine configuration file from
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
    LOG: Post-policy reference: System.Web.WebPages.Razor,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG:
    Attempting download of new URL
    file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
    ASP.NET Files/.../cb62a7b2/327a0353/System.Web.WebPages.Razor.DLL.
    LOG: Attempting download of new URL
    file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
    ASP.NET
    Files/.../cb62a7b2/327a0353/System.Web.WebPages.Razor/System.Web.WebPages.Razor.DLL.
    LOG: Attempting download of new URL
    file:///C:/LeGroupeHtmSVN/.../UpDir.Web/bin/System.Web.WebPages.Razor.DLL.
    WRN: Comparing the assembly name resulted in the mismatch: Major
    Version ERR: Failed to complete setup of assembly (hr = 0x80131040).
    Probing terminated.  </p>
    
    <p>Stack Trace: </p>
    
    <p>[FileLoadException: Could not load file or assembly
    'System.Web.WebPages.Razor, Version=2.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)]<br>
    Microsoft.Web.Helpers.PreApplicationStartCode.Start() +0</p>
    
    <p>[InvalidOperationException: The pre-application start initialization
    method Start on type Microsoft.Web.Helpers.PreApplicationStartCode
    threw an exception with the following error message: Could not load
    file or assembly 'System.Web.WebPages.Razor, Version=2.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).]<br>
    System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1
    methods) +11711966<br>
    System.Web.Compilation.BuildManager.CallPreStartInitMethods() +465<br>
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
    appManager, IApplicationHost appHost, IConfigMapPathFactory
    configMapPathFactory, HostingEnvironmentParameters hostingParameters,
    PolicyLevel policyLevel, Exception appDomainCreationException) +1167</p>
    
    <p>[HttpException (0x80004005): The pre-application start initialization
    method Start on type Microsoft.Web.Helpers.PreApplicationStartCode
    threw an exception with the following error message: Could not load
    file or assembly 'System.Web.WebPages.Razor, Version=2.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).]<br>
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700896
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
    +141    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
    wr, HttpContext context) +4869125</p>
    
    <p>-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319;
    ASP.NET Version:4.0.30319.272</p>
  </blockquote>
  
  <p>In my web.config file, and in my application, I am referencing System.Web.WebPages.Razor v1.0.0.0:</p>
  
  <blockquote>
  <pre><code>  &lt;dependentAssembly&gt;
      &lt;assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" /&gt;
      &lt;bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" /&gt;
    &lt;/dependentAssembly&gt;
  </code></pre>
  </blockquote>
  
  <p>I don't even know whether I could be using System.Web.WebPages.Razor v2.0.0.0 with .Net 4.</p>
  
  <p>Now, how do I find out what is referencing System.Web.WebPages.Razor v2.0.0.0?</p>