Skip to content

Application fails to start with FileNotFoundException (Could not load file or assembly ‘System.Net.Http, Version=4.0.0.0’ . . .) #876

Description

@zacharycmontoya

Affected .NET Tracer versions

1.18.0-1.19.1

Error message

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

Screenshot

(click image to enlarge)

system-net-http-filenotfoundexception

Preconditions

  • The application targets .NET Framework 4.6 or higher (does not affect .NET Core)
  • The application references System.Net.Http NuGet package
  • The application has a binding redirect on System.Net.Http to load a version higher than 4.0.0.0
  • An application assembly has an assembly reference to System.Net.Http 4.0.0.0
<!-- Filename: web.config -->

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

Status / Investigation

The team is already aware of the issue and we are actively working on a permanent fix with the highest priority.
We will update this comment thread with the diagnosis and with the time-line for a permanent resolution. In the meantime, affected customers can use the workaround below.

Workaround

Set the following registry keys in the Registry Editor:

  • In HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework, create a DWORD LoaderOptimization with the value of 1
  • In HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\.NETFramework, create a DWORD LoaderOptimization with the value of 1

In PowerShell, this can be done with the following commands:

New-ItemProperty -Path "HKLM:\Software\Microsoft\.NETFramework" -Name "LoaderOptimization" -Value 1
New-ItemProperty -Path "HKLM:\Software\WOW6432Node\Microsoft\.NETFramework" -Name "LoaderOptimization" -Value 1

Resolution

This issue has been resolved in .NET Tracer 1.19.2. Please update to this version

Additionally, if you have already applied the above workaround, please remove the workaround. To do this, delete the following registry keys in the Registry Editor:

  • In HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework, DWORD LoaderOptimization
  • In HKEY_LOCAL_MACHINE\Software\WOW6432Node\Microsoft\.NETFramework, DWORD LoaderOptimization

In PowerShell, this can be done with the following commands:

Remove-ItemProperty -Path "HKLM:\Software\Microsoft\.NETFramework" -Name "LoaderOptimization"
Remove-ItemProperty -Path "HKLM:\Software\WOW6432Node\Microsoft\.NETFramework" -Name "LoaderOptimization"

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions