The Background:
- Consuming application is a website built using .NET Core 3.1.
- Consuming application references a NuGet package built using .NET Standard 2.0.
- The consuming application has a reference to the latest version of the NuGet package and builds without any errors or warnings.
- The DLL from the NuGet package is visible in the
bin\debug\netcoreapp31\
andbin\release\netcoreapp31\
folders. - At runtime, at the first reference to any time in the NuGet package, a FileNotFound exception is thrown, reporting that the DLL from the NuGet package file cannot be found.
What I have tried:
- Verifying that the
PackageReference
entries in the.csproj
file is correct. Since it's a .NET Core application, there are no hint paths or assembly binding redirects that are interfering with assembly binding. - Clearing the NuGet cache.
- Removing and re-adding the NuGet package.
- Forcing NuGet to reinstall the package through the Package Manager Console.
- Cleaning and rebuilding the solution.
- Enabling Fusion Log Viewer and combing through the logs. This is where things get interesting. There are no entries in the logs indicating any attempts to resolve or load the assembly, or any entries indicating that the assembly bind failed.
The Question
What causes this particular exception when loading an assembly in a .NET Core application, and how do you resolve it?