2
votes

I had to make some changes to the ASP.NET MVC System.Web.Webpages dll. But when I replace the dll it throws me this error.

The type 'System.Web.WebPages.WebPageBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

3

3 Answers

4
votes

I had the same problem,

I eventually solved it by following the advice here.

And adding the following to my web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- … -->
  <system.web>
    <!-- … -->
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
      </assemblies>
    </compilation>
    <!-- … -->
  </system.web>
  <!-- … -->
</configuration>
2
votes

I found that the "copy Local" to true for the referenced "System.Web.Webpages" DLL helped in my case. I also had to do the same to some of the other DLLs as well.

1
votes

I got this error too when I was moving around directories within TFS. I fixed this error by opening NuGet and updating the MVC framework that was refererenced in all the DLLs.