【发布时间】:2019-04-23 11:24:38
【问题描述】:
我将 ASP.NET CORE 应用程序从 sdk .NET Core 2.0 升级到 .NET Core 2.1。 我可以在本地主机中运行该解决方案,但是当我将其部署到另一台服务器时出现异常。例外情况如下。 到目前为止,我为解决该问题所做的步骤如下,并且我所做的所有修改都引发了相同的错误,似乎没有任何效果。 有人对如何解决这个问题有任何建议吗?
我已经完成的步骤:
-
修改项目设置
<PropertyGroup> <TargetFramework>netcoreapp2.1</TargetFramework> <Platforms>AnyCPU;x64</Platforms> <RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion> <UseNETCoreGenerator>true</UseNETCoreGenerator> <RazorCompileOnBuild>true</RazorCompileOnBuild> </PropertyGroup> -
我还在 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
- 我还删除了我的 .vs 文件夹并关闭了我的 Visual Studio 并再次打开它。
例外:
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException:发生一个或多个编译失败:错误 CS1705:程序集版本=1.0.0.0,Culture=neutral,PublicKeyToken=null'使用'System.Runtime,版本=4.2。 1.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a',其版本高于引用的程序集'System.Runtime',标识为'System.Runtime,Version=4.2.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a'
【问题讨论】:
-
能否指定使用的System.Runtime包的版本?尝试将其更改为 4.2.0.0
-
嗨马文,感谢您的回复。我无法在 VS Community 上查看它,我尝试右键单击以查看它没有显示任何内容的版本。我看到它列在 .net core 2.1 下。我还在 CurrentApplication.deps.json 中将 System Run time 版本修改为 4.2.0.0。它仍然抛出相同的异常。
-
“我可以在我的本地主机中运行解决方案,但是当我将它部署到另一台服务器时出现异常。”你是怎么发表的?自包含还是依赖框架?在第二台服务器上,您安装了哪些先决条件?这是目前缺少的关键信息。
-
嗨 Lex Li,我将其发布为自包含。我还没有解决这个问题。但是我的另一个同事试图从她的机器上发布到服务器并且它工作。我们有相同的凭证和代码。
标签: asp.net-core .net-core startup .net-core-2.0 .net-core-2.1