Fix an Assembly Manifest Definition Mismatch

This error means .NET found a DLL, but the DLL’s identity does not match the assembly identity that your application or one of its dependencies requested. The reliable fix is to identify the requested assembly version, culture, and public key token; remove the conflicting reference or deployed DLL; then restore, rebuild, and deploy one consistent set of outputs.

Use this table to match the failure pattern to the likely repair.

When the error appears Likely cause First fix to try
Immediately after updating a package Direct and transitive dependencies resolve to incompatible assembly versions Inspect the package graph and align package references
Only after copying DLLs into bin, a publish folder, or an install directory A copied DLL replaced the assembly the app was built to load Remove manual copies and publish the whole application again
On a server or another developer’s machine, but not locally The deployed folder contains stale or missing private dependencies Replace the complete deployment output, not individual DLLs
In a .NET Framework application after a library upgrade The app requests an older assembly version than the installed compatible version Add a binding redirect if the newer assembly is binary-compatible
After replacing a runtime or framework-adjacent DLL with a custom build The custom assembly’s manifest version is lower or otherwise different from the reference Rebuild the custom assembly with the identity required by the consuming application

What the Assembly Manifest Mismatch Error Means

An assembly is the deployable unit of .NET code: usually a .dll or .exe containing compiled code, metadata, resources, and an assembly manifest. In Microsoft’s .NET assembly model, the manifest records the assembly’s identity and the assemblies it depends on.

An assembly reference is a requirement embedded in compiled code. It normally identifies another assembly by:

  • Assembly name
  • Version
  • Culture
  • Public key token for strongly named assemblies

For example, an application may request:

Contoso.Reporting, Version=3.2.0.0, Culture=neutral, PublicKeyToken=0123456789abcdef

If the runtime probes a directory and finds Contoso.Reporting.dll, it reads that file’s manifest. If the file instead identifies itself as version 2.8.0.0, has a different public key token, or has another incompatible identity difference, the loader rejects it with 0x80131040.

This is different from a simple “file not found” error. A manifest mismatch means the runtime located a candidate file but refused to load it.

The filename is not the assembly identity. Renaming a DLL to match the requested filename does not change the identity embedded in its manifest.

How to Fix the Manifest Definition Mismatch

Capture the requested assembly identity, inspect the deployed DLL, and correct the reference that introduced the conflicting version.

Step 1: Capture the Exact Assembly Request

Start with the full exception text, not only the final 0x80131040 message. Look for:

  1. The assembly name being requested.
  2. The requested version.
  3. The culture and public key token, if shown.
  4. The assembly or application that triggered the load.
  5. Whether the error happens at startup, when calling one feature, or only after deployment.

A useful exception message often looks like this:

Could not load file or assembly 'Contoso.Reporting, Version=3.2.0.0,
Culture=neutral, PublicKeyToken=0123456789abcdef' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.

Write down the full requested identity. Do not begin by replacing random DLLs in the output folder; that can hide the original conflict and create another one.

Also check whether the named assembly is the real problem. “Or one of its dependencies” means the assembly in the error can be the first failed load visible to the runtime, while a dependency beneath it is the mismatched file.

Step 2: Inspect the DLL That Is Actually Being Deployed

Find every copy of the failing DLL in your project output, publish directory, installer staging directory, container image, or target machine.

On Windows, PowerShell can read an assembly manifest without loading the assembly into your application:

[System.Reflection.AssemblyName]::GetAssemblyName(".\publish\Contoso.Reporting.dll").FullName

Replace the path with the DLL you are investigating. Compare the output with the assembly identity in the exception.

Check these common mismatches:

  1. The DLL has the same filename but a different version.
  2. The DLL was rebuilt with a different strong-name key, changing its public key token.
  3. A legacy project uses a HintPath to an old DLL outside the NuGet package cache.
  4. A build or installer copied an older DLL over the published file.
  5. Two packages bring different versions of the same dependency into the application.

For SDK-style projects, inspect direct and transitive package dependencies from the project directory:

dotnet list package --include-transitive

Look for multiple paths to the same package family, especially when one package requires an old major version and another requires a newer one.

Step 3: Correct the Reference at Its Source

Fix the project’s references rather than editing files in bin or renaming DLLs by hand.

For a package conflict:

  1. Update the direct package reference that controls the dependency version.
  2. Update or replace packages that require incompatible versions.
  3. Remove duplicate package references and old file-based references.
  4. Check .csproj, Directory.Packages.props, and any legacy packages.config or HintPath entries.
  5. Make sure all projects deployed together use compatible target frameworks and package versions.

For a project reference conflict:

  1. Remove references to old compiled copies of the library.
  2. Reference the current project or its intended package.
  3. Rebuild every project that consumes the changed library.

For a custom assembly, match the identity required by the application that consumes it. In the documented case of replacing System.Collections.Immutable in a .NET Core deployment, Microsoft .NET SDK guidance requires the custom immutable-collections build to use an assembly version of at least 4.2.1.0, which was the version used at compilation in that case. That number is not a universal version to assign to every custom DLL; inspect the consuming application’s reference and build the replacement with the identity it requires.

Do not attempt to solve a strong-name mismatch by copying an unsigned DLL over a signed one. A different public key token identifies a different assembly to the runtime.

Step 4: Rebuild and Publish a Clean, Complete Output

After correcting references, remove stale build output before producing a new deployment.

Run the following commands to clear stale build output, restore packages, and rebuild: dotnet clean dotnet restore dotnet build

dotnet clean
dotnet restore
dotnet build

For deployment, publish a fresh application folder rather than copying selected assemblies from bin:

dotnet publish -c Release -o ./publish

Deploy the complete contents of the publish folder, including the application DLL, dependency DLLs, .deps.json, runtime configuration files, native libraries, and any application content required by the app.

Private assembly dependencies must be in the application directory or a directory below the directory where the app is installed. A correct DLL stored elsewhere may still fail to resolve, while an obsolete DLL in the application directory can be selected before the intended one.

I reproduce one problem at a time in a clean container or virtual environment because it removes machine-specific files from the result.

Finish by running the published application from a clean destination folder. If it starts and executes the feature that previously failed without a load exception, the deployed assembly graph is consistent.

.NET Framework Binding Redirects and .NET Core

Binding redirects are a .NET Framework feature. They can tell a .NET Framework application to load one compatible version of a strongly named assembly when compiled code requested another version.

A typical redirect belongs in the application configuration file that is deployed next to the executable:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity
          name="Contoso.Reporting"
          publicKeyToken="0123456789abcdef"
          culture="neutral" />
        <bindingRedirect
          oldVersion="1.0.0.0-3.2.0.0"
          newVersion="3.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Replace the example assembly name, public key token, version range, and target version with the identities you inspected. The redirected assembly must be genuinely binary-compatible with the callers. A redirect can select a compatible newer version; it cannot make removed methods, changed behavior, or incompatible public APIs work.

For .NET Core and modern .NET applications, do not add binding redirects. Under Microsoft .NET SDK guidance for .NET Core, binding redirects are not used. Resolve the package graph, rebuild the application, and deploy the dependency versions selected by restore and publish.

Self-Contained Publish and Manual DLL Replacement

A self-contained publish contains the runtime and application dependencies needed for a particular runtime identifier. It can still fail if a DLL is replaced after publishing.

For example, replacing System.Collections.Immutable.dll in a publish folder with a custom build may leave the directory with a file whose manifest no longer matches the identity expected by the app, runtime, or another library. The fact that the replacement file has the same name is not enough.

Avoid this sequence:

  1. Publish the application.
  2. Copy a custom DLL over a published DLL.
  3. Run the app without checking the replacement assembly’s manifest.

Instead:

  1. Build the custom assembly as part of the solution or package it through the normal dependency process.
  2. Verify its manifest identity before publishing.
  3. Restore and publish the application with that dependency selected during build.
  4. Deploy the entire resulting publish directory.
  5. Test the exact deployment artifact, not a locally modified copy.

If a manual replacement is unavoidable for a controlled test, record the original DLL’s full identity and hash first, inspect the replacement identity, and restore the original file before creating a production deployment.

Collect an Assembly Load Trace on .NET Framework

When the exception text does not identify the wrong file, an assembly bind log can show what the loader requested, where it searched, and which candidate it rejected.

This applies to .NET Framework’s Fusion loader on Windows, not to .NET Core’s dependency-resolution model.

To enable assembly bind failure logging, set [HKLM\Software\Microsoft\Fusion!EnableLog] as a DWORD to 1. Administrator access is normally required because this is under HKEY_LOCAL_MACHINE.

Then:

  1. Reproduce the failure once.
  2. Review the assembly bind log for the requested identity, probing paths, and located candidate.
  3. Compare the requested identity with the manifest identity of the candidate DLL.
  4. Correct the project reference or deployment contents.
  5. Disable or remove the logging setting after collecting the diagnostic data.

The log is most useful when it reveals an unexpected probing path, such as an old application directory, a stale plugin folder, or a DLL installed by an older deployment.

Verify the Fix and Prevent It From Returning

Before closing the issue, verify both the build and deployment sides of the repair.

  • The exception’s requested assembly identity matches the deployed DLL’s manifest identity.
  • There is only one intended copy of the conflicting DLL in the application’s probing locations.
  • The project no longer contains obsolete HintPath references or manual copy steps.
  • The complete publish output was deployed together.
  • The target machine or container runs the same artifact you tested.
  • The application starts successfully and exercises the feature that previously triggered the load.

To prevent repeat failures, keep dependencies managed through project references and package restore. Avoid checking compiled third-party DLLs into random project folders, copying DLLs into publish output after the build, or mixing files from separate builds.

Frequently Asked Questions

What Is an Assembly Reference?

An assembly reference is metadata in a compiled .NET assembly that identifies another assembly it needs to load. It commonly includes the dependency’s name, version, culture, and public key token. At runtime, .NET compares that requested identity with the manifest in the DLL it finds.

Is “Could Not Load File or Assembly” the Same as a Manifest Mismatch?

No. “The system cannot find the file specified” usually means the runtime did not find a required file in its probing paths. “The located assembly’s manifest definition does not match the assembly reference” means it found a file but rejected it because its embedded identity differs from the requested identity.

Can I Use a Binding Redirect in .NET Core?

No. .NET Core does not use binding redirects. Fix the package or project references, rebuild with dotnet restore and dotnet build, then deploy the complete dotnet publish output.

How Do I Fix This Reference Error in Visual Studio?

Remove stale DLL references, package duplicates, and outdated HintPath entries, then add the intended project or NuGet package reference. Clean the solution, restore packages, rebuild, and test from a newly published folder rather than from an old bin directory.

Why Does Event Viewer Not Show Enough Manifest Information?

Event Viewer may show only the top-level FileLoadException and 0x80131040 code. For a .NET Framework application on Windows, enable Fusion bind failure logging by setting [HKLM\Software\Microsoft\Fusion!EnableLog] as a DWORD to 1, reproduce the failure, and inspect the requested identity and rejected file path.