简体   繁体   English

带有 .net framework 4.6.1 的 Asp.net Core 2.0 - 找不到参考程序集 '.NETFramework/v4.6.1/Microsoft.CSharp.dll

[英]Asp.net Core 2.0 with .net framework 4.6.1 - Cannot find reference assembly '.NETFramework/v4.6.1/Microsoft.CSharp.dll

I have recently upgraded my project from asp.net core 1.1 to asp.net core 2.0.我最近将我的项目从 asp.net core 1.1 升级到 asp.net core 2.0。 and app us using .Net framework 4.6.1.并使用 .Net 框架 4.6.1 应用我们。 Application is working as expected on local dev machine but once it deployed to server with dotnet publish command I am seeing this error应用程序在本地开发机器上按预期工作,但是一旦它使用 dotnet publish 命令部署到服务器,我就会看到这个错误

InvalidOperationException: Cannot find reference assembly '.NETFramework/v4.6.1/Microsoft.CSharp.dll' file for package Microsoft.CSharp.Reference InvalidOperationException:找不到包 Microsoft.CSharp.Reference 的参考程序集“.NETFramework/v4.6.1/Microsoft.CSharp.dll”文件

I have also noticed that ref folder that use be present when using asp.net core 1.1 when published is now missing.我还注意到在发布时使用 asp.net core 1.1 时使用的ref文件夹现在丢失了。 How to fix this issue.如何解决这个问题。

Same issue was resolved when MvcRazorCompileOnPublish was added to .csproj file.当 MvcRazorCompileOnPublish 添加到 .csproj 文件时,同样的问题得到解决。

Give it a try.试一试。

<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>

I noticed if you have the Views folder included with the compiled View.dll when you start your IIS pool, you get this error.我注意到如果在启动 IIS 池时编译的 View.dll 中包含 Views 文件夹,则会出现此错误。 I was doing this on purpose for a short term work around hack.我这样做是为了在 hack 周围进行短期工作。

在我的情况下(我在控制台应用程序模式下运行 .Net core)上述解决方案都不起作用,我只是从 这个链接下载了 .Net Framework 4.6.1。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.Net CORE 3.1 - 抛出错误异常:Microsoft.CSharp.dll 中的“Microsoft.CSharp.RuntimeBinder.RuntimeBinderException” - ASP .Net CORE 3.1 - Error Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in Microsoft.CSharp.dll asp.net核心目标框架4.6.1发布 - asp.net core target framework 4.6.1 publish 如何使用Asp.Net.Identity和Entity Framework 6在Asp.Net Core 2.0 Target Framework 4.6.1中设置身份? - How can I setup identity in Asp.Net Core 2.0 Target Framework 4.6.1 using Asp.Net.Identity and Entity Framework 6? 将Asp.Net应用程序从4.6.1降级到.Net Framework 4.5.2 - Downgrade Asp.Net application to .Net framework 4.5.2 from 4.6.1 Package 'Microsoft.AspNet.Mvc 5.2.7' 已使用 '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, - Package 'Microsoft.AspNet.Mvc 5.2.7' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, 集成测试C#WebAPI asp.NET Framework 4.6.1 - Integration testing C# WebAPI asp.NET Framework 4.6.1 在c#asp.net核心中获取图像尺寸(框架4.6.1) - Get Image dimensions in c# asp.net core (framework 4.6.1) WSFederation登录-Asp.net 4.6.1 - WSFederation Sign-in - Asp.net 4.6.1 带有 Asp.Net 4.6.1 的 Sentry SDK 不工作 - Sentry SDK with Asp.Net 4.6.1 Not working 使用dotnet发布或visual studio发布部署后,Asp.Net Core 2.1与.Net Framework 4.6.1错误 - Asp.Net Core 2.1 with .Net Framework 4.6.1 error after deployment using dotnet publish or visual studio publish
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM