1
votes

I upgraded my .Net framework on my solution from 4.5.2 to 4.8. I got some warnings initially and to fix them I did Update-Package -Id some.package –reinstall for all the packages in the warning.

Then it showed a generic warning and after looking in the diagnostics build log, I saw the following 4 warnings:

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".

and:

There was a conflict between "System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

and:

There was a conflict between "System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

and finally:

There was a conflict between "System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.IO, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

I have seen the solutions here and here and unfortunately they didn't help.

Now I managed to fix the System.Net.Http issue by changing the following in my *.csproj file as per suggestion of this post:

    <Reference Include="System.Net.Http">
      <HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
      <Private>True</Private>
    </Reference>

changed to:

<Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
      <Private>True</Private>
    </Reference>

However, I don't seem to figure out how to fix the System.Runtime and System.IO issues.

2
If you turn build verbose to detailed, it will tell you what is actually conflicting, be warned it may take a while to find the issueTheGeneral
@MichaelRandall, thank you, but that's how I got the details of the warning. So the ones in yellow above are from the diagnostics log.Stackedup
have you tried AutoRedirectBindings=True in project properties ?Clint
@Clint, thanks for the reply. Yes, I also tried that by doing Get-Project –All | Add-BindingRedirect. It only fixes the System.Net.Http but not the others.Stackedup

2 Answers

1
votes

Found conflict between System.Runtime as well as System.IO

It seems that you have referenced some older nuget package with higher assembly version when you upgrade your framework version.

You can follow my steps to troubleshoot your issue:

1) unload your project and add these into xxx.csproj file

<PropertyGroup>
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

After that, reload your project, clean and rebuild your project.

2) add a binding redirect in the web.config file.

<dependentAssembly>
        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
 </dependentAssembly>

<dependentAssembly>
        <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
 </dependentAssembly>

It uses the dll from the build extensions directory and not the one from Nuget.

Hope it could help you.

1
votes

I ended up installing Visual Studio 2019, then updated the properties on each project to use .Net framework 4.8 and ran through the updates and it just worked.