HRESULT 0x80131040 The located assembly's manifest definition does not match the assembly reference
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The error HRESULT 0x80131040 ("The located assembly's manifest definition does not match the assembly reference") occurs when the .NET CLR finds an assembly on disk but its version, culture, or public key token does not match what was requested at compile time. This is a FileLoadException — the file exists but is the wrong version. The most common fix is adding a binding redirect in your app.config or web.config to map the requested version to the version actually present.
The Error
This means the CLR found Newtonsoft.Json.dll but its embedded version number does not match 12.0.0.0. Perhaps version 13.0.0.0 is on disk while the code was compiled against 12.0.0.0.
Why This Happens
Version Mismatch Scenarios
Common triggers:
- NuGet package version conflicts — different projects reference different versions of the same package
- Transitive dependencies — Package X depends on Newtonsoft.Json 12.x, Package Y depends on 13.x
- GAC interference — an old version in the Global Assembly Cache overrides the local copy
- Strong naming — strong-named assemblies require exact version matches unless redirected
Fix 1: Add Binding Redirect
This tells the CLR: "Any request for Newtonsoft.Json versions 0.0.0.0 through 13.0.0.0, load version 13.0.0.0 instead." The newVersion must match the assembly version actually in your bin/ folder.
Fix 2: Enable Auto-Generated Binding Redirects
MSBuild analyzes all referenced assemblies and generates the correct redirects automatically in the output config file. This is the recommended approach for .NET Framework 4.5.1+ projects.
Fix 3: Consolidate NuGet Versions
In Visual Studio: right-click the solution, select Manage NuGet Packages for Solution, go to Consolidate, and align all projects to the same package version.
Fix 4: Clean and Rebuild
Sometimes the bin/ folder contains a leftover DLL from a previous package version. Cleaning removes all build artifacts and forces a fresh copy.
Fix 5: Check the GAC
The GAC takes priority over local assemblies. If an old version is registered globally, the CLR loads it instead of the version in your bin/ folder.
Diagnosing with Fusion Log
Enable the Assembly Binding Log Viewer to see exactly what the CLR is doing:
The Fusion log shows every step the CLR takes: which paths it probes, what version it finds, and why the binding failed.
Finding the Actual Assembly Version
The newVersion in your binding redirect must match this actual version.
.NET Core / .NET 5+ Projects
This error is much less common in .NET Core and .NET 5+ because they use a different assembly loading model that is more lenient about versioning:
If you still encounter it in .NET Core, it is usually because a NuGet package bundles the wrong DLL version. Update the package or file an issue with the package maintainer.
Common Pitfalls
- Wrong
newVersionin redirect: ThenewVersionmust match the assembly version in your bin/ folder, not the NuGet package version. Assembly version13.0.0.0may come from NuGet package13.0.3. Check withAssemblyName.GetAssemblyName(). - Missing
publicKeyToken: If you omitpublicKeyTokenin theassemblyIdentity, the redirect is ignored for strong-named assemblies. Get the token from the error message or usesn -T assembly.dll. - Config file not deployed: The
app.configis copied to<assembly>.exe.configon build. If you edit the config manually in the output folder, it gets overwritten on the next build. Always edit the sourceapp.config. - Multiple config transforms: Web projects may have
web.Debug.configandweb.Release.configtransforms that add or remove binding redirects depending on the build configuration. Check the transformed output, not just the base config. - NuGet restore restores old versions: If
packages.lock.jsonorpackages.configreferences an old version,dotnet restorebrings back the old DLL. Delete the lock file and restore again, or update the package reference first.
Summary
- HRESULT
0x80131040means the CLR found an assembly but its version does not match the requested version - Add a binding redirect in
app.config/web.configto map old versions to the version on disk - Enable
AutoGenerateBindingRedirectsin your.csprojfor automatic resolution - Consolidate NuGet package versions across all projects in your solution
- Use Fusion Log Viewer (
fuslogvw.exe) to diagnose exactly which version the CLR is finding - This error is rare in .NET Core/.NET 5+ due to a more flexible assembly loading model

