Skip to content
Latchkey

System.IO.FileLoadException assembly version conflict at runtime in CI

FileLoadException differs from FileNotFoundException: the assembly file was found, but its identity (version, public key, culture) does not match what the caller requested. It is a binding conflict where two components disagree on which version of a shared dependency should load.

What this error means

The app or test throws System.IO.FileLoadException saying the located assembly's manifest definition does not match the assembly reference. It is deterministic for the deployed binaries.

dotnet
System.IO.FileLoadException: Could not load file or assembly 'System.Text.Json,
Version=8.0.0.0'. The located assembly's manifest definition does not match the assembly
reference.

Common causes

Conflicting versions of a shared assembly

Two dependencies require different versions of the same assembly, and the one that shipped does not match a caller's reference.

A stale or duplicate assembly in output

An old copy in the output directory or a cached bin shadows the expected version.

How to fix it

Unify the version and clean output

  1. Pin a single version of the conflicting assembly (direct reference or Central Package Management).
  2. Delete bin/obj so no stale copy remains, then rebuild/publish.
  3. Re-run.
shell
dotnet list package --include-transitive | grep -i System.Text.Json

How to prevent it

  • Use Central Package Management to keep one version of shared assemblies.
  • Avoid caching bin directories that can carry stale assemblies.

Frequently asked questions

What causes ""FileLoadException: ... does not match""?
Two dependencies require different versions of the same assembly, and the one that shipped does not match a caller's reference.
How do I fix "FileLoadException: ... does not match"?
Unify the version and clean output

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card