c# – Can’t launch a 6 month old Visual Studio .NET project without updating runtime


I did a prototype console web project (Minimal APIs) some 5 months ago in Visual Studio 2022 and now I want to restart work on it. However, when I try to run the .exe, I get the following message.

It was not possible to find any compatible framework version
The framework ‘Microsoft.NETCore.App’, version ‘6.0.6’ (x86) was not found.

  • The following frameworks were found:
    • 5.0.12 at [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
    • 5.0.17 at [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
    • 6.0.0 at [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

If I try to debug it from VS, I get the message

The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program ‘[30812] TodoApi.exe’ has exited with code 2147516566 (0x80008096).

Now, I know that I can just install the new runtime and be done with it, but I don’t understand why I’m forced to upgrade the runtime in an otherwise unchanged project. I haven’t updated Visual Studio 2022 in that time either.

If I just straight upgrade, then it can happen again in the future, and I would like to know why.

The .csproj is

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <PlatformTarget>x86</PlatformTarget>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <Platforms>AnyCPU;x64</Platforms>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
  </ItemGroup>

</Project>

Project Configuration

No idea what other information could be relevant, sorry.

Edit: I thought about adding dotnet –info output, and now I see .NET 6.0.6 in host, which I guess is the problem?

.NET SDK (reflecting any global.json):
 Version:   6.0.106
 Commit:    e83a22f558

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.106\

Host (useful for support):
  Version: 6.0.6
  Commit:  7cca709db2

.NET SDKs installed:
  6.0.100 [C:\Program Files\dotnet\sdk]
  6.0.106 [C:\Program Files\dotnet\sdk]

I guess it was a Windows update? How do I turn it back to 6.0.1? I do not have a global.json file.

Leave a Reply

Your email address will not be published. Required fields are marked *