Could not load file or assembly 'System.Web.WebPages'

前端 未结 7 435
孤街浪徒
孤街浪徒 2020-12-20 11:45

I\'ve had this problem before, but then all i needed to do was to clean and rebuild the project. Now that doesnt seem to work anymore. When i start my Asp.Net MVC3 project d

相关标签:
7条回答
  • 2020-12-20 12:08

    Go to menu: "Tools / Nuget Package Manager / Package Manager Console"

    run command install-package Microsoft.AspNet.WebPages

    0 讨论(0)
  • 2020-12-20 12:19

    I scratched my head for a while over this problem when I had it. Eventually I noticed that I had the following section in the "runtime" section of my web.config.

    <runtime>
     . . .
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
          </dependentAssembly>
    . . .
    </runtime>
    

    As you can see, this refers to version 2 of the assembly, which doesn't match the following code that you also have in the system.web/compilation/assemblies section of web.config.

    <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    

    The actual assembly referenced in References for the project is indeed v1.0.0.0, so I changed the first chunk of code above to the following, which fixed the problem immediately. I'm not sure how the mistake got there in the first place.

    <runtime>
     . . .
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
          </dependentAssembly>
    . . .
    </runtime>
    
    0 讨论(0)
  • 2020-12-20 12:21

    I had this issue, all I had to do was change the property of the external reference: Specific Version from True to False

    After that the project build again.

    0 讨论(0)
  • 2020-12-20 12:24

    Worked for me:

    1. Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution

    2. Browse

    3. Search for "Microsoft.AspNet.WebPages"

    4. Make sure all projects in solution have the latest version.

    0 讨论(0)
  • 2020-12-20 12:30

    I had this problem. Maybe it occurred when I installed .NET MVC v4 over the top of MVC v3, not sure.

    Anyway I removed the System.Web.WebPages reference from my project. Then in the Add Reference dialogue .NET tab there were two System.Web.WebPages references listed, a version 1.0.0.0 and a 2.0.0.0. I made sure to add the version 1.0.0.0 one as that was the one that was missing.

    enter image description here

    0 讨论(0)
  • 2020-12-20 12:31

    The solution for me was to go to my server and install the Web Pages Version 2 on the server.

    Go to http://www.microsoft.com/en-us/download/details.aspx?id=34600

    And download the package and run it.

    It was as simple as that.

    0 讨论(0)
提交回复
热议问题