C
C#3y 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
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.
1 Reply
Stroniax
StroniaxOP3y ago
@calledude Reinstalled how? I just went to microsoft and installed .net 6.0 SDK, but still nothing. However the error says it's looking for System.Runtime version 7, which I believe the dotnet watch command is trying to use based on the error message, and not the actual run command...

Did you find this page helpful?