MSB3277: Found conflicts between different versions of 'assembly' that could not be resolved

This error occurs during a build when more than one version of the same dependent assembly is referenced in a build of the same project. In a .NET build, all assemblies that are referenced, directly or indirectly through other referenced assemblies, have to resolve to the same version. You cannot reference two different and conflicting versions of the same assembly when building the same binary. The error is emitted by the ResolveAssemblyReference task, which looks at all the referenced assemblies, and all of the assemblies referenced indirectly by those assemblies, and so on, until all assembly references have been resolved.

Diagnosing the error

To diagnose the error, first enable a diagnostic log (use the -verbosity:diag command-line switch), and check the MSBuild log file with the full diagnostics output. For bigger output logs on large projects, consider using the binary log (-bl command-line switch) and the MSBuild Structured Log Viewer to view the output more easily. When this error occurs with MSBuild 16.x or later, the specific versions that are in conflict are written to the log file. If you're using an earlier version of MSBuild, this isn't in the log file, but you can usually follow the dependency chain to find the conflicting reference. Look at each of the assemblies your project references, and which assemblies those assemblies reference, and so on until you find the conflicting version(s).

The diagnostics log should specify not only which assembly versions were in conflict but exactly why they were considered, that is, there was a reference to assembly1.dll, which referenced assembly2.dll version x, but there was also a reference to assembly2.dll version y, and MSBuild could not figure out which was the right version to use. The following is an excerpt from a diagnostic log showing a conflict between two versions of StreamJsonRpc:

There was a conflict between "StreamJsonRpc, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "StreamJsonRpc, Version=2.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
    "StreamJsonRpc, Version = 2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "StreamJsonRpc, Version=2.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
    References which depend on "StreamJsonRpc, Version = 2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\user\.nuget\packages\streamjsonrpc\2.1.74\lib\netstandard2.0\StreamJsonRpc.dll].
    C:\Users\user\.nuget\packages\streamjsonrpc\2.1.74\lib\netstandard2.0\StreamJsonRpc.dll
          Project file item includes which caused reference "C:\Users\user\.nuget\packages\streamjsonrpc\2.1.74\lib\netstandard2.0\StreamJsonRpc.dll".
            C:\Users\user\.nuget\packages\streamjsonrpc\2.1.74\lib\netstandard2.0\StreamJsonRpc.dll
        C:\Users\user\.nuget\packages\microsoft.servicehub.framework\2.0.72\lib\netstandard2.0\Microsoft.ServiceHub.Framework.dll
          Project file item includes which caused reference "C:\Users\user\.nuget\packages\microsoft.servicehub.framework\2.0.72\lib\netstandard2.0\Microsoft.ServiceHub.Framework.dll".
            C:\Users\user\.nuget\packages\microsoft.servicehub.framework\2.0.72\lib\netstandard2.0\Microsoft.ServiceHub.Framework.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.15.0\16.4.29318.21\lib\net472\Microsoft.VisualStudio.Shell.15.0.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.datadesign.common\16.0.28321-alpha\lib\net472\Microsoft.VisualStudio.DataDesign.Common.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.projectsystem\16.2.133-pre\lib\net472\Microsoft.VisualStudio.ProjectSystem.VS.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.design\16.0.28316-pre\lib\net45\Microsoft.VisualStudio.Shell.Design.dll
            C:\Users\user\.nuget\packages\microsoft.vsdesigner\16.0.28321-alpha\lib\net472\Microsoft.VSDesigner.dll
        C:\Users\user\.nuget\packages\microsoft.visualstudio.language\16.0.428\lib\net472\Microsoft.VisualStudio.Language.dll
          Project file item includes which caused reference "C:\Users\user\.nuget\packages\microsoft.visualstudio.language\16.0.428\lib\net472\Microsoft.VisualStudio.Language.dll".
            C:\Users\user\.nuget\packages\microsoft.visualstudio.language\16.0.428\lib\net472\Microsoft.VisualStudio.Language.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.editor\16.0.428\lib\net472\Microsoft.VisualStudio.Editor.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
        C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
          Project file item includes which caused reference "C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll".
            C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
        C:\Users\user\.nuget\packages\microsoft.visualstudio.utilities\16.4.29317.144\lib\net46\Microsoft.VisualStudio.Utilities.dll
          Project file item includes which caused reference "C:\Users\user\.nuget\packages\microsoft.visualstudio.utilities\16.4.29317.144\lib\net46\Microsoft.VisualStudio.Utilities.dll".
            C:\Users\user\.nuget\packages\microsoft.visualstudio.utilities\16.4.29317.144\lib\net46\Microsoft.VisualStudio.Utilities.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.imaging\16.4.29317.144\lib\net472\Microsoft.VisualStudio.Imaging.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.15.0\16.4.29318.21\lib\net472\Microsoft.VisualStudio.Shell.15.0.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.datadesign.common\16.0.28321-alpha\lib\net472\Microsoft.VisualStudio.DataDesign.Common.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.projectsystem\16.2.133-pre\lib\net472\Microsoft.VisualStudio.ProjectSystem.VS.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.design\16.0.28316-pre\lib\net45\Microsoft.VisualStudio.Shell.Design.dll
            C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.framework\16.4.29318.21\lib\net472\Microsoft.VisualStudio.Shell.Framework.dll
            C:\Users\user\.nuget\packages\microsoft.vsdesigner\16.0.28321-alpha\lib\net472\Microsoft.VSDesigner.dll
    References which depend on "StreamJsonRpc, Version = 2.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].

You can also set the MSBuildDebugEngine environment variable to 1 to get all possible logs. See Building MSBuild for the .NET Framework - Logs.

Common fixes

Depending on the root cause of the conflict, the fix might be to update the version of an assembly on disk, perhaps by upgrading or reinstalling a NuGet package or SDK. If you simply want to update all packages to the latest versions, you can run the command Update-Package -reinstall from the Package Manager Console in Visual Studio. See Reinstalling and updating packages. However, it could be that you intentionally have more than one version of the referenced assembly on disk, but your project or one of its dependencies needs to be updated so that it's referencing the latest version of the conflicting assembly that you have installed. The Global Assembly Cache (GAC) might also be a source of a potential conflict, in cases where you are referencing a specific version of an assembly, but the GAC overrides it. See Global Assembly Cache.

Third-party components

If the conflict is in a third-party component, the component might not be supported with the version of the conflicting assembly you're using in your project. Look to the third party to see if they offer an updated, compatible version. If that's not available, the solution might be to downgrade the version of the conflicting assembly you're referencing to match the version that the third party component uses.

Binding redirects

In some cases, your project might specify or might need to specify binding redirects, which force calls to use a specified version of an assembly. See Redirecting assembly versions to understand how binding redirects work. Visual Studio or settings in project files can enable or disable automatic binding redirection. See How to: Enable and disable automatic binding redirection. Check the settings and make sure you understand how and why your project is using binding redirects.

Loading multiple versions of the same assembly

In advanced scenarios, it could also be that you're working with a project that intentionally requires more than one version of the same assembly. You can use special techniques to override the normal assembly loading process to accomplish the goal. See Resolve assembly loads. Be sure to understand and follow the guidance in Best practices for assembly loading.

See also