1

I'm using Visual Studio 2019 and I have a multi targeted framework which targets .NET Framework 4.72 and .NET Core 5.0.

The multi targeted .csproj is configured as follows:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net472;net5.0</TargetFrameworks>
    <PlatformTarget>x86</PlatformTarget>
    ...

When I try to debug a .NET Core executable, I'm getting this error:

A fatal error has occurred and debugging needs to be terminated. The debugger was configured to use the Desktop CLR (.NET Framework) Managed debugger, but the target process loaded the CoreCLR (.NET Core) runtime. To debug this project, configure it to use the 'Managed (CoreCLR)' debugger.

Nir
  • 1,836
  • 23
  • 26

2 Answers2

0
  1. Flip the frameworks order in the .csproj file so the Core framework will be first: <TargetFrameworks>net5.0;net472</TargetFrameworks>

  2. Set "Enable native code debugging" in the project debug configuration. enter image description here

Nir
  • 1,836
  • 23
  • 26
0

Try running Visual stuiod as Administrator user and it should be fine. It happened with me and just running IDE as administrator fixed it.

Nishant Joshi
  • 61
  • 1
  • 3