Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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:

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'

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.

There is no project.json to update. I already included the Microsoft.NETCore.Portable.Compatibility NuGet package to no effect.

What is causing this, and how can I fix it?

like image 760
Sarov Avatar asked Oct 21 '25 15:10

Sarov


2 Answers

Right-Click on your project and click Clean Solution in Visual Studio, and then try building it again. 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.

like image 84
Hassnain Ali Avatar answered Oct 24 '25 04:10

Hassnain Ali


I also faced the same issue, I got this when I was trying to install EntityFramework. Code Clean-Up worked for me. Go to analyze and then try to run code cleanup using both profiles.

like image 31
Sujan Budathoki Avatar answered Oct 24 '25 04:10

Sujan Budathoki