How to solve the issue: Could not load file or assembly xxx or one of it’s dependencies.
While working with .NET, especially .NET Framework, you might encounter this error when updating or cloning your project. It can even occur suddenly. This error can be caused by several factors, including:
- A change in the NuGet package or one of its dependencies
- A corrupted file or assembly
- Working on an old project
- Conflicts with NuGet packages
- An obsolete NuGet cache
If you delve deeper into the Stack Trace, you might get more details:
System.IO.FileLoadException: ‘Could not load file or assembly ‘xxx.xxx, Version=xxx, Culture=neutral, PublicKeyToken=xxx’ or one of its dependencies
The culprit may be your NuGet cache. To address this, try running the following commands:
// Clear the local NuGet cache to ensure that the latest versions of the packages are used.
dotnet nuget locals all --clear
// Clean and rebuild the solution to ensure all references are updated.
dotnet clean
dotnet build
If this still doesn’t work, you might then need to manually resolve the configuration files (app or web config).