1
votes

Within my web project I updated the target framework from version 4.5 to 4.6 and now I am getting a runtime error. I dont know why its looking for a System.Runtime, Version=4.0. Any help would be great.

From

<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

To

<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>

web.config Update

<httpRuntime targetFramework="4.6" maxRequestLength="1024000" executionTimeout="150000"/>
<compilation targetFramework="4.6" debug="true"/>


 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="12.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="dotless.Core" publicKeyToken="96b446c9e63eae34" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.0" newVersion="1.5.2.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

Runtime Error

Compiler Error Message: CS0012: The type 'System.IEquatable`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Updated to 4.7.2

<httpRuntime targetFramework="4.6" maxRequestLength="1024000" executionTimeout="150000"/>
<compilation targetFramework="4.7.2" debug="true"/>

Runtime Error

Compiler Error Message: CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

1
Lets look at your assembly binding redirects - T.S.
@T.S. I updated with the assembly binding. - Jefferson
you can try something stupid - shut down visual studio and reopen the project. Or... probably, when you updated the target framework, you now taking reference from a different DLL in one of the packages. You might need to update packages. And I think, I know this issue. 4.6 is a weird version. It is kinda netstandard compatible, but it needs bunch of additional DLLs - like the System.Runtime. You should go to 4.7.2 - this is fully netstandard2.0 compatible and you will lose this problem. - T.S.
Yeah, to echo what @T.S. said. Since you're upgrading the target framework to 4.6, why not go all the way to 4.8? - phuzi
Avoid 4.6 - welcome. Why would you need to go incremental? New FW supports all the old stuff. Just convert to the latest, compile and see if it works. If does - check-in - T.S.

1 Answers

0
votes

I was able to fix this by Enable latest C# and VB features for ASP.NET Project. Thanks all for the help.