The nuget package Microsoft.Net.Http.2.0.20710.0 is causing me a build warning because of its use of System.Net.Http, Version=2.0.0.0 which is fighting with version 4 coming from another package.
What is the best way around this? Is the package Microsoft.Net.Http.2.0.20710.0 outdated, should I just reference System.Net.Http, Version=4.0.0.0 manually in my project?
The build output is:
There was a conflict between "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
"System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:WorkingMyProjectpackagesMicrosoft.Net.Http.2.0.20710.0libnet40System.Net.Http.dll].
C:WorkingMyProjectpackagesMicrosoft.Net.Http.2.0.20710.0libnet40System.Net.Http.dll
Project file item includes which caused reference "C:WorkingMyProjectpackagesMicrosoft.Net.Http.2.0.20710.0libnet40System.Net.Http.dll".
System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
References which depend on "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.Net.Http.dll].
C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.Core.4.0.20710.0libnet40System.Web.Http.dll
Project file item includes which caused reference "C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.Core.4.0.20710.0libnet40System.Web.Http.dll".
System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.Client.4.0.20710.0libnet40System.Net.Http.Formatting.dll
Project file item includes which caused reference "C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.Client.4.0.20710.0libnet40System.Net.Http.Formatting.dll".
System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.WebHost.4.0.20710.0libnet40System.Web.Http.WebHost.dll
Project file item includes which caused reference "C:WorkingMyProjectpackagesMicrosoft.AspNet.WebApi.WebHost.4.0.20710.0libnet40System.Web.Http.WebHost.dll".
System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
C:WindowsMicrosoft.NETFrameworkv4.0.30319Microsoft.Common.targets(1578,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can try the workaround mentioned in this Microsoft Connect bugreport.
Or you can try and add something like this to your Web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Edit:
This is the workaround in the Connect Bug:
modify…….: <Reference Include=”System.Net.Http”>
to read ……: <Reference Include=”System.Net.Http, Version=4.0.0.0″>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0