I had similar issue on:
Windows 11
VS Code 1.98.2
.NET SDK 5.0.408
Error message when running project:
Unable to find the project that contains '{project_location}\Program.cs'
Error message when opening project
2025-05-09 12:49:08.054 [info] Cannot use file stream for [{VSCode install path}\data\extensions\ms-dotnettools.csdevkit-1.19.60-win32-x64\components\CPS\platforms\win32-x64\node_modules\@microsoft\visualstudio-projectsystem-buildhost.win32-x64\Microsoft.VisualStudio.ProjectSystem.Server.BuildHost.runtimeconfig.json]: No such file or directory
Invalid runtimeconfig.json [{VSCode install path}\data\extensions\ms-dotnettools.csdevkit-1.19.60-win32-x64\components\CPS\platforms\win32-x64\node_modules\@microsoft\visualstudio-projectsystem-buildhost.win32-x64\Microsoft.VisualStudio.ProjectSystem.Server.BuildHost.runtimeconfig.json] [{VSCode install path}\data\extensions\ms-dotnettools.csdevkit-1.19.60-win32-x64\components\CPS\platforms\win32-x64\node_modules\@microsoft\visualstudio-projectsystem-buildhost.win32-x64\Microsoft.VisualStudio.ProjectSystem.Server.BuildHost.runtimeconfig.dev.json]
2025-05-09 12:49:08.773 [info] Project system initialization finished. 0 project(s) are loaded, and 1 failed to load.
Solution was to install .NET 5 and .NET 9 SDKs in the same location and start project with selection of .NET version
# download script
iwr -outf dotnet-install.ps1 https://dot.net/v1/dotnet-install.ps1
#install Net 5
.\dotnet-install.ps1 -Version 5.0.408 -InstallDir DestinationDir
#install Net 9
.\dotnet-install.ps1 -Version 9.0.203 -InstallDir DestinationDir
Note: If you don't specify destrination dir default one will be used.
Check if installation is ok:
dotnet --version
# example output
9.0.203
Check if all versions installed sdks and runtimes are available.
dotnet --list-sdks
# example output
5.0.408 [C:\Users\user\AppData\Local\Microsoft\dotnet\sdk]
9.0.203 [C:\Users\user\AppData\Local\Microsoft\dotnet\sdk]
Creation of new project with such setup
# make project folder and navigate in
mkdir project_folder
cd project_folder
# Create global.json in project folder with specified .NET version
dotnet new globaljson --sdk-version 5.0.408 --force
# Create project - console example
dotnet new console
Inspiration to this solution was this article: Dotnet Core Binaries and multiple SDK installations
Similar discussion: https://github.com/microsoft/vscode-dotnettools/issues/789