简体   繁体   English

.Net Framework 您必须添加对程序集 mscorlib 的引用,版本 = 4.0.0.0

[英].Net Framework You must add a reference to assembly mscorlib, Version=4.0.0.0

After updating and including some NuGet packages, I now get many compile errors similar to:更新并包含一些 NuGet 包后,我现在收到许多类似于以下内容的编译错误:

The type 'Object' is defined in an assembly that is not referenced. “对象”类型是在未引用的程序集中定义的。 You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'您必须添加对程序集 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 的引用

I looked at You must add a reference to assembly mscorlib, version=4.0.0 but I'm not running .Net core - this is an ASP.NET MVC, .Net Framework 4.7.2 Project.我查看了您必须添加对程序集 mscorlib,版本 = 4.0.0 的引用,但我没有运行 .Net 核心 - 这是一个 ASP.NET MVC,.Net Framework 4.7.2 项目。

There is no project.json to update.没有要更新的 project.json。 I already included the Microsoft.NETCore.Portable.Compatibility NuGet package to no effect.我已经包含了 Microsoft.NETCore.Portable.Compatibility NuGet 包,但没有效果。

What is causing this, and how can I fix it?这是什么原因造成的,我该如何解决?

Right-Click on your project and click Clean Solution in Visual Studio, and then try building it again. 右键单击您的项目,然后单击Visual Studio中的Clean Solution,然后再次尝试构建它。 Solves the problem most of the time for me. 我大部分时间都在解决这个问题。 Or else, in case you copy-pasted a class from somewhere else, try creating a new class in your project and instead, copy-paste the code within the other class instead of just copying the class itself. 或者,如果您从其他地方复制粘贴一个类,请尝试在项目中创建一个新类,而是将代码复制粘贴到另一个类中,而不是仅仅复制类本身。

I also faced the same issue, I got this when I was trying to install EntityFramework.我也遇到了同样的问题,我在尝试安装 EntityFramework 时遇到了这个问题。 Code Clean-Up worked for me.代码清理对我有用。 Go to analyze and then try to run code cleanup using both profiles.转到分析,然后尝试使用两个配置文件运行代码清理。

For completeness's sake, I'll include the fix that actually worked for me as an answer.为了完整起见,我将包含对我实际有用的修复程序作为答案。

Just delete the repo, re-clone, and try again.只需删除存储库,重新克隆,然后再试一次。

暂无
暂无

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

相关问题 “MarshalByRefObject”类型是在未引用的程序集中定义的。 您必须添加对程序集 'mscorlib, Version=4.0.0.0 的引用 - The type 'MarshalByRefObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0 您必须添加对程序集 mscorlib 的引用,版本=4.0.0 - You must add a reference to assembly mscorlib, version=4.0.0 您必须添加对程序集'mscorlib,Version = 2.0.5.0 ...'的引用C#WP7 XNA - You must add a reference to assembly 'mscorlib, Version=2.0.5.0…' C# WP7 XNA 可移植类库-您必须添加对程序集'System.Net,版本= 2.0.5.0的引用 - Portable Class Library - you must add a reference to assembly 'System.Net, Version=2.0.5.0 您必须添加对程序集'WindowsBase,Version = 3.0.0.0的引用 - You must add a reference to assembly 'WindowsBase, Version=3.0.0.0 ASP.NET:由Nuget引起的.NET Framework /标准/核DLL冲突。 “你必须添加对程序集System.Runtime的引用......” - ASP.NET: .NET Framework/Standard/Core DLL collisions, caused by Nuget. “You must add a reference to assembly System.Runtime…” 无法从程序集'mscorlib,版本= 4.0.0.0加载类型'System.Runtime.CompilerServices.ExtensionAttribute'错误 - Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0 Error 无法从程序集“ mscorlib”中加载类型'System.Threading.AsyncLocal`1',版本= 4.0.0.0,区域性=中性, - Unable to load type 'System.Threading.AsyncLocal`1' from the assembly 'mscorlib, Version = 4.0.0.0, Culture = neutral, “Csc”任务意外失败无法从程序集 mscorlib Version=4.0.0.0 加载类型 System.ValueTuple 3, - The “Csc” task failed unexpectedly Could not load type System.ValueTuple 3 from assembly mscorlib Version=4.0.0.0, 无法从程序集“mscorlib,版本=4.0.0.0”加载类型“System.Security.Cryptography.SHA256Managed” - Could not load type 'System.Security.Cryptography.SHA256Managed' from assembly 'mscorlib, Version=4.0.0.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM