简体   繁体   中英

Error after updating .NET Framework 4.6.1 to 4.8

I updated my application from .NET Framework 4.6.1 to 4.8 but I have an error loading the application.

For context: This application uses the Ninject Nuget for dependency injection. This nuget automatically creates a file called "NinjectWebCommon.cs" inside the App_Start folder In this ninject file I am having an error with the StandardKernel(); method

 private static IKernel CreateKernel()
    {
        var kernel = new StandardKernel();

The error I am having is this:

System.IO.FileNotFoundException: 'Cannot load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'

Searching for a solution I found that I needed to have inside the Web.config a binding redirect, but I already have it.

 <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0"/>
  </dependentAssembly>

I also have on the project references System.Net.Http, so I don't know what could it be

I deleted the dependentAssembly for System.Net.Http and it worked. I don't know if that is the optimal solution btw

I had a similar problem. This is what I did to resolve it, AFTER upgrading to 4.8.

  1. Removed NuGet Package System.Net.Http
  2. Re-Added the Reference System.Net.Http
  3. In App.config removed the bindingredirect line for system.net.http

Worked like a charm!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM