1

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Stackedup
  • 680
  • 2
  • 9
  • 26
  • 1
    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 issue – TheGeneral Feb 09 '20 at 03:32
  • @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 Feb 09 '20 at 04:54
  • 1
    have you tried `AutoRedirectBindings=True` in project properties ? – Clint Feb 09 '20 at 06:03
  • @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 Feb 09 '20 at 06:59

2 Answers2

1

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.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • Perry, thank you for the reply. Unfortunately, it didn't fix it. It actually added one more error for ``System.Runtime.CompilerServices.Unsafe``. – Stackedup Feb 12 '20 at 06:39
  • Perry, I did try this as well and didn't make any difference. Also yes, I used ``Update-Package -Id some.package –reinstall``, one by one on the packages that the warning specified. On a different branch I also tried to do the re-install on all packages but similar problems. – Stackedup Feb 13 '20 at 10:30
  • Perry, thank you very much for the replies. I had actually tried that as well and didn't have any luck. So I decided to install Visual Studio 2019. Once I did this and ran through the package updates, it just worked. Thanks again anyway. – Stackedup Feb 14 '20 at 23:22
1

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.

Stackedup
  • 680
  • 2
  • 9
  • 26