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.
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
- Pin a single version of the conflicting assembly (direct reference or Central Package Management).
- Delete
bin/objso no stale copy remains, then rebuild/publish. - Re-run.
dotnet list package --include-transitive | grep -i System.Text.JsonHow to prevent it
- Use Central Package Management to keep one version of shared assemblies.
- Avoid caching
bindirectories that can carry stale assemblies.