Reputation: 373
I'm upgrading my solution from .NET 5 to .NET 6 and getting the error at runtime
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'NLog.Web.AspNetCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'. The system cannot find the file specified. File name: 'NLog.Web.AspNetCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c' at MyApp.Program.CreateHostBuilder(String[] args) at MyApp.Program.Main(String[] args) in ..\MyApp\Program.cs:line 18
I'm using NLog 4.7.15
, and NLog.Web.AspNetCore 4.15.0
nuget packages. The versions did not change during upgrade. As soon as I upgraded all my projects in the solution, I started getting that error at runtime, both on Windows and macOS. As soon as I switch back to .NET 5 the error goes away. I tried upgrading to NLog 5.0.0-rc2
and I get the same error but just Version=5.0.0.0
. Downgrading the packages had no effect either.
I'm also using JetBrains Rider.
I'm clueless how to approach this problem. I've searched the web and haven't found any working solutions.
Upvotes: 3
Views: 2219
Reputation: 373
Appears to be a bug in .NET 6
Having this property in the project file was causing the issue
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
Removing it solved it. Not the best solution as I need to use that property. Will have to open up an issue with .NET team.
EDIT: Created an issue with them: https://github.com/dotnet/runtime/issues/68720
Upvotes: 2