C#C
C#4y ago
Stroniax

dotnet watch run FileNotFoundException (System.Runtime 7.0)

After updating Visual Studio, which installed the .NET 7.0 SDK, I can no longer use dotnet watch run on my project. I have made no other changes (all target frameworks are still 6.0). dotnet run works just fine, but when I use dotnet watch run the solution builds and then fails with the following exception:
dotnet watch 🚀 Started
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
   at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
   at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
   at System.StartupHookProvider.ProcessStartupHooks()

dotnet watch ❌ Exited with error code -532462766


I was expecting that the update alone wouldn't break anything, at least until I updated my project(s)... I can't find anything on Google except for creating a
global.json
file or possibly changing the target framework, which I do not yet want to do because I want to stick with LTS for this project.
Was this page helpful?