Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 844
Hussein Salman Avatar asked Mar 30 '16 21:03

Hussein Salman


Video Answer


1 Answers

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

like image 59
Hussein Salman Avatar answered Oct 23 '22 21:10

Hussein Salman