dotnet
assembly_loading
ai_generated
true
System.IO.FileNotFoundException: Could not load file or assembly 'AssemblyName, Version=x.x.x.x'. The system cannot find the file specified.
ID: dotnet/filenotfoundexception
87%Fix Rate
90%Confidence
70Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 8 | active | — | — | — |
Root Cause
FileNotFoundException for assemblies occurs when the runtime cannot locate a required DLL. Common causes include missing NuGet dependencies, incorrect publish output, or version mismatches in binding redirects. Fix by restoring packages and verifying the publish output.
genericWorkarounds
-
87% success Run dotnet restore and verify all NuGet packages are properly resolved
Run 'dotnet restore --force' to re-resolve all dependencies. Check the output for warnings about missing or conflicting packages. If using a private NuGet feed, verify the feed URL and credentials in nuget.config
-
85% success Publish as self-contained with all dependencies included
Run 'dotnet publish -c Release --self-contained -r linux-x64' to include all runtime dependencies in the output. This avoids reliance on globally installed assemblies and ensures all required DLLs are in the publish directory
Dead Ends
Common approaches that don't work:
-
Manually copying DLL files into the output directory
75% fail
Creates fragile deployments that break on updates; the underlying dependency resolution issue remains and will resurface when packages are updated or the project is rebuilt on another machine
-
Downgrading the target framework to match an older assembly version
70% fail
Introduces compatibility issues and loses access to newer APIs; the version mismatch often indicates a transitive dependency conflict that needs proper resolution, not framework downgrade
Error Chain
Preceded by:
Frequently confused with: