skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

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


  2. 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!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search