Search code examples
c#dllvisual-studio-2017mscorlib

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.


Solution

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