9

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 and obj 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.

7
  • Is the problem related to the project or does a new project show the same result ? Commented Oct 21, 2024 at 12:58
  • A new project doesn't show the same result Commented Oct 21, 2024 at 13:06
  • 1
    It may be a good case to "report a problem" to microsoft. They may look into it, ask for logs, instruct you how to get logs, look at first error in logs (totally unrelated), tell you something unrelated and then stop talking to you.. or your experience may be more pleasant and resultful. Commented Oct 21, 2024 at 14:18
  • Try probing the assembly loading process using the COREHOST_TRACE* environment variables, and progressively increasing the VERBOSITY level. See if the log gives you anything useful. Commented Oct 23, 2024 at 4:09
  • If it worked before my guess is a nuget reference got updated ? Check all recent changes to the code and maybe you find something that changed. Commented Oct 23, 2024 at 6:29

2 Answers 2

2

Open Terminal and run below command to check whether the runtime is installed or not.

dotnet --list-runtimes

you can direct download .Net core runtime using below link

.Net Core Runtime Version 8.0.0.0

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, it is installed... I'm not sure there's something else I need to do in order for the project to access it but it was working three days ago without me doing anything so I don't know.
1

My .NET8 solution had two projects - and EXE and a DLL. The DLL was mistakenly set as the startup project. Changing it to the EXE project fixed this error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.