VS 2015 : Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0

13,860

Solution 1

Solution: install Microsoft.AspNet.Webpages first release of version 2.0 via nuget manager.

Solution 2

I would start by looking at assembly binding failures - this will show you which assembly is requesting that failing binding.

There is a handy little tool you can use to view your binding failures. This should help you track it down.

https://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.71).aspx

Good luck!

Share:
13,860
Hussein Salman
Author by

Hussein Salman

Engineering Manager & Cloud-Native Architect, focusing on Kubernetes, Containers & Microservices. Check out my youtube channel: https://www.youtube.com/channel/UCoAh8g6dmwXQUwKhkggUFIA

Updated on June 19, 2022

Comments

  • Hussein Salman
    Hussein Salman almost 2 years

    I am running a solution which contains different projects. However, i am trying to run a project (class library) which contains wcf services using Visual Studio 2015 and framework 4.6 (on windows 8 OS, IIS Express). However it keeps showing this error in the browser:

    Error:

    enter imag*e description here

    I noticed that the calling assembly of Razor 2.0 is "System.Web.Mvc" Version 4.0.0.1:

    Calling assembly : System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

    However, System.Web.MVC dll is not referenced in this project, the references in the project are in the image below:

    enter image description here

    Although, it is not referenced it always appears in the bin folder, even when i clear it. And may be that's why it is trying to call "System.Web.WebPages.Razor" version 2.0.

    Clarifying any clues of the problem:

    1. I have no related assembly in the Web.Config that calls System.web.mvc

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
          </dependentAssembly>
         
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    1. also not included in package config:

    <packages>
      <package id="EntityFramework" version="6.1.3" targetFramework="net46" />
      <package id="Microsoft.AspNet.Providers" version="2.0.0" targetFramework="net451" />
      <package id="Microsoft.AspNet.Providers.Core" version="2.0.0" targetFramework="net451" />
      <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" />
      <package id="PostSharp" version="4.3.5-alpha" targetFramework="net46" />
      <package id="System.Web.Providers" version="1.2" targetFramework="net451" />
    </packages>
    1. not included as a reference

    I am wondering about whats going on? may another project affects it! Also i have tried to use nugget to update the packages (uninstalled and reinstalled), but still in the same situation.

    A possible reason of the problem:

    I also noticed there is a "Gobal.asax" file in this project which uses "MvcApplication" class that implements "System.Web.HttpApplication" which may be a good reason of the problem.

    Any help is appreciated.

  • KnowHoper
    KnowHoper about 8 years
    PS location here: C:\Program Files (x86)\Microsoft SDKs\Windows{version}\bin{.NET Version Tools}
  • sethu
    sethu over 6 years
    This helped me.
  • AS7K
    AS7K over 6 years
    This helped me, too.
  • Robert Bolton
    Robert Bolton about 6 years
    Thank you this fixed my problem
  • Matstar
    Matstar almost 5 years
    I also deleted my bin folder
  • Novikov
    Novikov over 4 years
    And delete obj folder too. Sometimes copy-paste of project is not a good idea.