Shlomi Toren
Shlomi Toren

Reputation: 63

MSB3258: mscorlib 4.0.0.0 and 2.0.0.0

So I'm trying to compile a project on VS 2017, and I'm getting this:

 warning MSB3258: The primary reference "someLib.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.

After that, I have errors relating to this dll (for example, a type or namespace not being in the namespace), but when I double click the error it disappears, along with the red squiggly line in the code, hinting at the fact that it's not the actual problem.

Nothing I tried is working: all of the projects are on 3.5, I removed and re-added all of my references, and it doesn't happen in any other computer except my own. I also tried removing mscorlib from the GAC (however dumb that may be), but of course it won't let me.

I saw something that may be relevant: https://developercommunity.visualstudio.com/content/problem/230636/assemblydependency-now-misidentifying-indirect-dep.html

Other than removing and reinstalling VS, not sure what to do. If anyone has any idea, I'd be glad to try it.

Upvotes: 4

Views: 7093

Answers (2)

Shlomi Toren
Shlomi Toren

Reputation: 63

It was a weird reference to a version of Interop.Shell32.dll called just "Shell32.dll". Don't know where it came from.

If anyone else has this issue: remove each dependency one at a time and compile. Even the Microsoft ones.

Upvotes: 1

ProdigioM
ProdigioM

Reputation: 474

Answer from comments:

Check the libraries someLib.dll references. Maybe they contain a reference to mscorlib.dll 4.0.0.0.

Hint: add official Microsoft libraries via Via Add Reference > "Assemblies tab" (on the left, don't know if tab is correctly named). Don't add them by browsing for them.

Upvotes: 0

Related Questions