DotNetOpenAuth causing a can not load Assembly System.Web.WebPages.Razor

后端 未结 3 528
没有蜡笔的小新
没有蜡笔的小新 2021-01-22 04:25

My local version of my code runs just fine. But when I do a web deploy I am getting the following exception:

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

相关标签:
3条回答
  • 2021-01-22 05:04

    Place this in your web.config file. It will cause the framework to redirect dependencies to the appropriate version.

    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <configuration>
    

    Edit from the future

    As I revisit this post because of a XML error pointed out in the above syntax, there are a few other places that most likely need updated as well. First, in the primary web.config, this line should be changed in the <appSettings> section to the following

    <appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
    

    Also, there is a web.config in the views folder that should be updated to the following

     <configSections>
        <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
          <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
        </sectionGroup>
      </configSections>
    

    Basically, you want to identify all of the places that mention razor 2.0.0.0 and change those to 3.0.0.0 in addition to the assembly redirect. I believe I have all of those locations identified above.

    If you update the entire MVC framework, there is additional work that would need to be performed as well, but that is not the basis for the question.

    0 讨论(0)
  • 2021-01-22 05:10

    I had the same problem. I was deploying to an Azure website where I had previously deployed an MVC4 app. I fixed it by "removing additional files at destination".

    Right click on project->publish->Settings->expand File Publish Options-> check Remove additional files at destination.

    0 讨论(0)
  • 2021-01-22 05:10

    I use Git deployment and was having the same issue. I didn't see an option where I could remove additional files at destination.

    I used FTP to connect to the Azure Host and then deleted everything in the /site/wwwroot directory. Then I used the Management Portal, Deployments tab, and finally the Sync command (i.e. redeploy) and that fixed the issue.

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