System.Runtime,版本= 4.2.1.0,PublicKeyToken = b03f5f7f11d50a3a具有比引用程序集更高的版本 [英] System.Runtime, Version=4.2.1.0, PublicKeyToken=b03f5f7f11d50a3a has a higher version than referenced assembly

查看:1218
本文介绍了System.Runtime,版本= 4.2.1.0,PublicKeyToken = b03f5f7f11d50a3a具有比引用程序集更高的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将ASP.NET CORE应用程序从sdk .NET Core 2.0升级到了.NET Core 2.1。
我可以在本地主机中运行该解决方案,但是当我将其部署到另一台服务器时,会出现异常。而且下面是例外。
到目前为止,我已经完成解决该问题的步骤,并且在进行所有修改后都抛出了相同的错误,似乎没有任何效果。
有人对如何解决此问题有任何建议吗?

I upgraded my ASP.NET CORE application from sdk .NET Core 2.0 to .NET Core 2.1. I can run the solution in my localhost but when I deploy it to another server there is an exception. And the exception is below. The steps I have done to solve the issue so far are below and it throws the same error with all the modification that I did seems nothing works. Does anybody have any suggestion how to solve this issue?

我已经完成的步骤:


  1. 修改以下设置项目

  1. Modify the setting for the project

 <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <Platforms>AnyCPU;x64</Platforms>
    <RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion>
    <UseNETCoreGenerator>true</UseNETCoreGenerator>
    <RazorCompileOnBuild>true</RazorCompileOnBuild>
  </PropertyGroup>


  • 我还在web.config中添加了绑定重定向

  • I also added binding redirect in the web.config

    <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"
    bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.1.0" 
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.1.0" />
      </dependentAssembly>
    </assemblyBinding>
    


  • 在服务器上安装.net core 2.1

  • Install .net core 2.1 on the server

    例外:


    Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException:发生一个或多个编译失败:错误CS1705:程序集版本= 1.0.0.0,文化=中性,PublicKeyToken = null使用 System.Runtime,版本= 4.2.1.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a,其版本高于引用程序集 System.Runtime,标识为 System.Runtime,版本= 4.2。 0.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a'

    Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred:error CS1705: Assembly Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'


    推荐答案

    我遇到了同样的问题。当我将解决方案中的 Views 文件夹添加到 publish 文件夹时,问题就消失了。由于某些原因,Razor要求这些源文件必须存在于服务器中并且是最新的,即使它也将它们编译为.dll。因此,奇怪的是Views文件夹在发布过程中没有自动复制。

    I had same problem. When I added the Views folder from the solution to the publish folder then the problem went away. For some reason Razor requires these source files to be present in the server AND up-to-date even when it compiles them also into .dll. Therefore it is strange indeed that the Views folder is not automatically copied during publish.

    我亲自建立了这样的路口,即

    junction MyProject\bin\Release\netcoreapp2.1\ \linux-x64\publish\Views MyProject\Views

    I personally made a junction like this
    junction "MyProject\bin\Release\netcoreapp2.1\linux-x64\publish\Views" "MyProject\Views"

    或者,禁用以下行可能有帮助(没有经过测试,但由于在Net.Core的早期版本中没有Razor编译,因此这个问题似乎是相关的。

    Alternatively, disabling the following line might help (have not tested but this issue seems to be related since in earlier versions of Net.Core there was no Razor compilation).

    < RazorCompileOnBuild> true< / RazorCompileOnBuild>



    < RazorCompileOnBuild> false< / RazorCompileOnBuild>

    这篇关于System.Runtime,版本= 4.2.1.0,PublicKeyToken = b03f5f7f11d50a3a具有比引用程序集更高的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆