Strange issue with System.Net.Http 4.2.0.0 not found
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
The error Could not load file or assembly 'System.Net.Http, Version=4.2.0.0' is a common .NET assembly binding issue caused by version mismatches between the System.Net.Http NuGet package and the version shipped with the .NET runtime. The NuGet package (version 4.3.x) references assembly version 4.1.1.x, while .NET Framework 4.7.1+ ships assembly version 4.2.0.0. This mismatch causes FileNotFoundException or FileLoadException at runtime. The fix is to add a binding redirect in your app.config or web.config, or remove the NuGet package and rely on the framework-provided assembly.
The Error
This typically appears when:
- Your project targets .NET Framework 4.6.1+ and references the
System.Net.HttpNuGet package - A dependency (like
Microsoft.AspNet.WebApi.Client) requiresSystem.Net.Http 4.2.0.0 - The NuGet package provides version
4.1.1.xbut the runtime expects4.2.0.0
Why This Happens
Microsoft ships System.Net.Http in two places with different version numbers:
| Source | Assembly Version | NuGet Package Version |
| .NET Framework 4.7.1+ | 4.2.0.0 | N/A (built into framework) |
NuGet package System.Net.Http | 4.1.1.2 | 4.3.4 |
| .NET Framework 4.6.x | 4.0.0.0 | N/A |
When a NuGet dependency requests System.Net.Http 4.2.0.0 but the NuGet package only provides 4.1.1.2, the assembly loader cannot find the exact version and throws an exception.
Fix 1: Add a Binding Redirect (Most Common)
Add or update the binding redirect in app.config or web.config:
This tells the CLR to redirect any request for System.Net.Http versions 0.0.0.0 through 4.2.0.0 to the version actually available at runtime.
Fix 2: Remove the NuGet Package
If you are targeting .NET Framework 4.7.1 or later, the framework already includes System.Net.Http. Remove the NuGet package to avoid the conflict:
Then clean and rebuild:
After removal, the project uses the framework-provided assembly (4.2.0.0), which matches what dependencies expect.
Fix 3: Auto-Generate Binding Redirects
Enable automatic binding redirect generation in your .csproj:
The build process examines all referenced assemblies and generates the correct redirects in the output config file. This handles System.Net.Http and any other version mismatches automatically.
Fix 4: Consolidate NuGet Package Versions
When multiple projects in a solution reference different versions of System.Net.Http:
In Visual Studio: right-click the solution, select Manage NuGet Packages for Solution, go to the Consolidate tab, and align all projects to the same version.
Fix 5: Copy Local and Specific Version
If binding redirects do not work, force the correct assembly to be copied to the output:
Setting Private to true (Copy Local = Yes) ensures the NuGet version is in the output directory. Setting SpecificVersion to false allows any version to satisfy the reference.
.NET Core / .NET 5+ Projects
This issue primarily affects .NET Framework projects. .NET Core and .NET 5+ handle assembly versioning differently:
If you are migrating from .NET Framework to .NET 5+, remove any explicit System.Net.Http NuGet references. The namespace is available by default.
Diagnosing the Issue
Common Pitfalls
- Binding redirect
newVersionmismatch: ThenewVersionin the binding redirect must match the version that is actually present on disk or in the GAC. Check the actual assembly version in yourbin/folder, not the NuGet package version. - Multiple config files: Web projects use
web.config, console/desktop apps useapp.config. ASP.NET projects may also have transforms (web.Release.config) that override redirects. Verify the correct config file is being modified. - NuGet restore overwrites redirects: Running
Update-Package -reinstallor switching NuGet package versions can regenerate binding redirects. If you manually edited redirects, they may be overwritten. EnableAutoGenerateBindingRedirectsto avoid this. - GAC interference: If
System.Net.Httpis installed in the Global Assembly Cache with a different version, the CLR loads the GAC version instead of the local copy. Usegacutil /l System.Net.Httpto check. - Multi-targeting confusion: Projects targeting both
net461andnetstandard2.0may resolve different versions ofSystem.Net.Httpfor each target. Test both targets independently and ensure binding redirects exist for the .NET Framework target.
Summary
- The error is caused by assembly version mismatches between the NuGet
System.Net.Httppackage and the .NET Framework built-in version - Add a binding redirect in
app.config/web.configto resolve version conflicts - For .NET Framework 4.7.1+, removing the NuGet package and using the built-in assembly is often the cleanest fix
- Enable
AutoGenerateBindingRedirectsin your.csprojfor automatic resolution - .NET Core / .NET 5+ projects do not have this issue —
System.Net.Httpis part of the SDK - Use Fusion Log Viewer or runtime reflection to diagnose which version is actually loaded
Related reading
- Streaming video from Android camera to server
- stringByAppendingPathComponent is unavailable
- Support for Tensorflow 2.0 in Object Detection API
- Suppress InsecureRequestWarning Unverified HTTPS request is being made in Python2.6
- Stream CopyToAsync never returns
- Stream.Seek0, SeekOrigin.Begin or Position 0
- Strange MySQL Popup Mysql Installer is running community mode
- Strange OutOfMemory issue while loading an image to a Bitmap object

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.