52

On a new Win8.1 reinstall, with all of my code restored from backup, I'm suddenly now getting a Visual Studio warning when I build the main project of my solution:

Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

I set the Output log level to Detailed and I found a few entries like this:

There was a conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes". "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it had a higher version.

Trouble is, I'm not referencing mscorlib anywhere in the solution—old or new. I have a couple of apps on my machine that require .NET 3.5, but I can't see how that could be related.

One difference: the old Win8.1 install on which this warning did NOT occur was a standalone machine; this time I'm domain-joined. I don't know whether that makes a difference (I can't see how), but I thought I ought to mention it at least.

1
  • I'm facing same issue. Commented May 28, 2018 at 13:17

8 Answers 8

30

Having different versions of a Nuget package on different projects may cause this problem as well. Make sure that all your packages have the same version:

  1. (Within Visual Studio) Right click on the solution
  2. Click on Manage Nuget packages for Solution
  3. Click on the Consolidate tab
  4. For every package in the Consolidate tab, update the package to the same version for every project.
3
  • this is the right way to do it. worked great for us - clearly shows which packages have multiple versions and provides one-click method for resolving the specific issues - much more sane than a full-reinstall.
    – geekzster
    Commented May 17, 2017 at 18:49
  • 16
    @memetolsen: What if at "Consolidate" tab there is no packages to be updated? Any other recommendation? Commented Oct 10, 2017 at 0:46
  • 1
    Consolidate does not find any packages even though the projects are sharing them (at least it does not work in VS2019)
    – MC9000
    Commented Feb 16, 2020 at 14:38
22

I was able to fix this by issuing an update-package -reinstall command at the Package Manager Console.

BUT

Be careful, updating all the packages in your solution could cause other problems, make sure you can roll back to a good version if it goes wrong!

12
  • 1
    Man--that's been bugging me forever. Thanks for the tip! Commented Nov 2, 2015 at 23:41
  • 10
    Be careful, updating all the packages in your solution could cause other problems, make sure you can roll back to a good version if it goes wrong! Commented Nov 19, 2015 at 15:59
  • 2
    @user1069816: Yes, agreed.
    – InteXX
    Commented Dec 12, 2015 at 3:46
  • 1
    Hope this works, I did it before reading all the comments lol
    – Worthy7
    Commented Dec 1, 2016 at 5:52
  • 1
    @Worthy7: Not sure I follow you. "...how to to fix it"—do you mean running the command broke something or that the command didn't change anything and you're still getting the warning?
    – InteXX
    Commented Dec 7, 2016 at 20:55
12

I have been able to fix this issue by deleting my ".suo" file of my solution and then re-opening the solution. I then rebuild the solution and the issue is gone.

The ".suo" file is within the ".vs" folder which is what I usually delete.

Good luck!

2
  • This sounds like a good trick, certainly less expensive and less risky than a full package reinstall. I'll try it next time that pops up (which is sure to happen sooner or later).
    – InteXX
    Commented Jul 20, 2016 at 7:17
  • It was the only way that worked for me, when I updated one of the specific package I was having troubles (System.Net.Http), the mscorlib, System.Core and System was still showing conflicts in detailed mode of output. When I deleted the .suo, and opened again, the messages were gone. Commented Oct 6, 2017 at 14:53
10

I solved this by setting my verbosity to Diagnostic as per this answer.

Once I did that and rebuilt my solution, the build log actually listed the specific packages that depend on the two different versions of mscorlib.

In my particular case, my project had references to version 2.0.20126.16343 of System.Net.Http. I opened up the NuGet Package Manager and updated this package to the latest version (4.3.4 at the time). The next time I built my solution, the warnings were gone.

1
  • 1
    I followed this advice and discovered this issue had nothing to do with the mscorlib! The root cause turned out to be a missing keystore file. Commented Aug 28, 2019 at 4:17
7

Well my solution is a little bit simpler than all of the above. I simply added a reference to the two Assemblies throwing this error (System.Runtime.Serialization and mscorlib) and rebuilt the project. By doing this, I specified the 4.0.0.0 version and removed the ambiguity.

One of the two (mscorlib) couldn't be added via the GUI because of the "A reference to 'mscorlib' could not be added. This component is already automatically referenced by the build system." error.

I needed to open the .vbproj (.csproj) file and add a reference manually via:

<Reference Include="mscorlib" />
1
  • 3
    Worked for me too!
    – danicode
    Commented Jan 16, 2019 at 20:48
2

I've tried all the following, but none has resolved the issue.

  1. the command "update-package -reinstall".
  2. Update and package via Consolidate tab.
  3. Removing the ".suo" file.

However, My issue was a different case, I guess the new version of Xamarin.Forms package has used a different version of mscorlib. so I've downgraded it and it works fine.

I suggest you try all above solutions and also try to find which package is conflicting.

1

Following Memet Olsen's advice using VS2017 community...almost identical:

  • Right click Solution in Solution Explorer.
  • Select 'Manage Nuget Packages for Solution'
  • Check the packages. If any of them have a blue up-arrow rather than a green tick use the 'update' button
1

I also have tried all of the proposed solution to no avail.

In my project, this warning message was caused by a dll reference having a dependency on a different .net framework than the one that is targeted by my project.

In order to find out which dll reference was causing the warning, I simply used .net reflector to explore each dll reference to find out which one was referring a different .net framework (mscorlib).

In order to fix the issue, the reference dll has to be updated to a version which targets the same .net framework as the project using it, if such a version exist.

Hope this helps.

2
  • This behaviour is strange. If a library (.dll) is targeted on an earlier .NET Framework, it should run naturally on higher .NET Framework. Otherwise, .NET Framework is bad on compatibility. Why does this even be a warning?
    – zhoudu
    Commented May 7, 2024 at 7:17
  • If I remember correctly, this happened more often when a reference is added by a NuGet package. Sometimes, NuGet packages do not provide a DLL version that targets the same .net framework as the project that consumes the NuGet...
    – Sup3rHugh
    Commented May 8, 2024 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.