gogo
gogo

Reputation: 429

Found conflicts between different versions of the same dependent assembly that could not be resolved error

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.

It's happened after I'm import Newtonsoft.Json to my App.Core(Portable) project.

After a look in the output:

There was a conflict between "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". (TaskId:90) 2> "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not. (TaskId:90)

What I need to do now?

Upvotes: 27

Views: 34704

Answers (8)

Tony
Tony

Reputation: 393

I fixed this warning by removing the Microsoft.CSharp reference from my Android-specific csproj file. Microsoft.CSharp did not appear in the Android-specific Packages for my project in Visual Studio Solution Explorer, but the reference to CSharp was in the Android .csproj file. Specifically, I removed this line from my Android csproj file:

  <Reference Include="Microsoft.CSharp" />

At the time of the error (and fix), my environment was as follows:

  • Visual Studio Community 2019 for Mac (running in Big Sur 11.5.1)
  • Xamarin PCL project building for both iOS and Android
  • Xamarin.Forms version 5.0.0.2012
  • Newtownsoft.Json version 13.0.1

Upvotes: 3

KUTlime
KUTlime

Reputation: 8117

I had this problem at my Xamarin.Forms project with Android-only solution.

The fix was easy: Linking the latest Newtonsoft.Json directly to my Android project and the shared library.

The warning emerged when I've linked some NuGet package that was relying on the old version of Newtonsoft.Json package with a different, incompatible version C#.

Upvotes: 2

FreakyAli
FreakyAli

Reputation: 16562

If you are using Portable Libraries, there is a known problem with certain versions of the NuGet client which causes a build error in the Xamarin.iOS and Xamarin.Android projects when they have a reference to these build packages. The error message will say something similar to

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

To resolve this issue, remove the following references from the Xamarin.iOS and Xamarin.Android platform-specific project - leave the package, just delete the references from the References folder. You should be able to build at that point.

  • System.Runtime

  • System.IO

  • System.Threading.Tasks

For more information on this error, see this MSDN blog post.

Upvotes: 0

Dpedrinha
Dpedrinha

Reputation: 4230

I fixed it by updating Newtonsoft.Json package.

Upvotes: 11

Nick Bauer
Nick Bauer

Reputation: 1072

Newtonsoft.Json is relying on a newer version of the Microsoft.CSharp assembly than your project is referencing. You can remove the reference to the old library and add the newer one. The newer one may be in your packages directory for your solution, or you may be able to get the NuGet package. In my case, the only reference that depended on the old version of the CSharp library was itself, so there was no harm in doing this.

Upvotes: 1

gogo
gogo

Reputation: 429

The problem it's the Newtonsoft.Json NuGet, after I down his version the warning just go.

Probably a plug-in issue with Windows 10.

Upvotes: 0

pwhe23
pwhe23

Reputation: 1334

I was able to fix this by adding the Microsoft.CSharp NuGet package to my project. Previously I just had a reference to the Microsoft.CSharp assembly under the project references, but I wasn't using NuGet to pull it in. After using NuGet the message on my VSTS build server went away.

Upvotes: 1

Nick Kimbrough
Nick Kimbrough

Reputation: 316

I fixed this issue by downgrading my version of Newtonsoft.Json to 8.0.3, that was the newest version that didn't cause this error on build. I am unsure as to why this was the fix however.

Upvotes: 10

Related Questions