Subscribe Now: Feed Icon

Monday, February 14, 2011

mscorlib: Could not resolve this reference

I have decided to split my post “Rebuild All failed without any errors (Silverlight)” since for one of the build problems I found a solution.

So, to recap I have changed the Build Details: Options->Projects and Solutions->Build and Run->MSBuild project build output verbosity: from Minimal to Detailed. And found this message:

Dependency "mscorlib, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e".
    Could not resolve this reference. Could not locate the assembly "mscorlib, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Required by "System.Windows.Interactivity".

I actually questioned myself – How can the build not find mscorlib?


Restarting the VS didn’t solve this problem, but looking deeper into the Detailed Build Report did. I found this:

There was a conflict between "mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e".
    "mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "mscorlib, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" was not.
    References which depend on "mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll].
        C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll

References which depend on "mscorlib, Version=, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" [].
          Project file item includes which caused reference "C:\Projects\Libraries\System.Windows.Interactivity.dll".

And fixed the problem. Apparently my team’s web project (for some unknown reason) referenced “System.Windows.Interactivity.dll” which is a Silverlight Dll – I still don’t understand why it didn’t appear as either a warning nor an error.

At least it gave me a reason to go over my project references with Resharper “Find code dependent on module” and removed those references that are not used (something I hate to do, the guys at Resharper have actually put a vote on something to fix this – please enter and vote).


Keywords: Silverlight, reference, VS2010, Resharper