I have been working on a .NET 8 project in Visual Studio for months. Everything was working well until one day out of nowhere, without changing anything in the code/OS/VS the project started throwing this exception whenever I try to run it:
Could not load file or assembly "System.Runtime version=8.0.0.0"
Here's what I've tried and hasn't worked:
- Reinstalling Visual Studio
- Reinstalling .NET
- Repairing .NET
- Restoring NuGet packages
- Deleting
bin
andobj
folders from my project, cleaning and rebuilding the solution - Cloning the repository again
- Manually reinstalled NuGet packages/dependencies
- Deleting NuGet cache
- Manually installed
System.Runtime
via NuGet (it wasn't previously installed but it used to work just fine)
Curiously enough, when I try to run the project in Rider instead of VS on a different machine, the project runs just fine. I have seen many people encounter this error online but none of their approaches worked for me.
The .sln
has only one project whose .NET version is 8.