85

I want to debug an empty WebApi Project based on .NET Core 2.2.

I installed the "Core 2.2 SDK x86" and changed the target framework to 2.2:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

When I started to debug this project, IIS starts, but in the route api/values I see nothing (it loads forever) and I get this error:

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

In my solution WPF and Class Library projects exist. I wanted to make a WebApi for it. Like I said, it's an empty base project generated by Visual Studio 2019. I just installed Core 2.2. Why do I get that error and what am I doing wrong?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
michasaucer
  • 4,562
  • 9
  • 40
  • 91
  • Did you create the project from the "ASP.NET Core Web Application" Template? – Arnaud VdP Apr 19 '19 at 07:00
  • Yes, i create from Core's `WebApi` – michasaucer Apr 19 '19 at 07:00
  • For now i downgraded my proj to `2.1` – michasaucer Apr 19 '19 at 07:16
  • To check whether it is related with this solution, please try to create a new web api .net core 2.2 project, will it work? Try to run command `dotnet --list-sdks` and `dotnet --list-runtimes` and share us the result. – Edward Apr 22 '19 at 07:53
  • Having this issue too, and I never upgraded to 2.2. None of the below suggestions have worked so far. – Dylan Nicholson Dec 12 '19 at 22:45
  • I am getting this error when I run the project from other drives, it works as expected from the C drive. – Vivek Nuna Oct 02 '21 at 07:03
  • I've got the same error message, but in my case I noticed I had a line `win-x86` in my project (inherited from a "Directory.Build.props" file). Since my container is Linux, I guess setting the runtime identifier to `win-x86` is not allowed. Removing the line, solved the issue. – Marco Thomazini Feb 24 '23 at 17:04

32 Answers32

38

I had the same issue.
I ran Program.cs file from the command line and the error message was different.
So, apparently, I didn't have the appropriate .NET Core runtime installed.

You can download it by the following link - https://dotnet.microsoft.com/download

spottedmahn
  • 14,823
  • 13
  • 108
  • 178
24

I was facing the same issue!

I updated my Visual Studios to the most recent via the VS Installer.
While updating, I also added the following VS Workloads:

  • ASP.NET and web development
  • .NET desktop development

See about workloads here:
https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/install/modify-visual-studio.md

This worked for me!

I did not have to downgrade or remove anything

Quymbee
  • 249
  • 2
  • 7
24

I had to do a "clean" and "rebuild" of the project and after that it worked again.

Enrico
  • 2,734
  • 1
  • 27
  • 40
20

I ran with the same problem. But for me it was that my project was running in .NET Core 2.2, which I didn't have installed. I'm using VS 2019.

So for the solution, just go to Visual Studio Installer and for your VS 2019 hit "Modify" like in the following image (it's in spanish though): See image here

Then, click "Individual Components", like here.

And then, make sure you checked in ".NET Core 2.2 Runtime (EOL)" (and above like .NET Core 3.0, if you want) and click "Modify", as shown here

Hope this works for you.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
Bazil
  • 429
  • 4
  • 6
  • Hey @Bazil, welcome to Stack Overflow. This is useful information for someone who doesn't have the .NET Core 2.2 Runtime installed. That said, it's worth noting that in the OP's case, at least, they had already installed the .NET Core 2.2 SDK, which includes the .NET Core 2.2 Runtime. – Jeremy Caney Jan 31 '20 at 21:43
  • Solved my problem, thought in my case it was .net 7 which was missing. – René AD Apr 21 '22 at 19:10
10

It seems like there are lots of different causes for this. For me, it was because I had upgraded a .csproj file but I hadn't updated the image used in my docker file.

Image showing a 'FROM' line in a dockerfile using a dotnet image on version 5

Toby Smith
  • 1,505
  • 2
  • 15
  • 24
8

In my case, switching to x64 save the day. enter image description here

maxisam
  • 21,975
  • 9
  • 75
  • 84
5

I had same issue after package upgrading. You don't need any vs update. Just go to dotnet.microsoft.com/download/dotnet-core/2.2 and get runtime dotnet-hosting-2.2.7-win.

Vlad Hrona
  • 387
  • 3
  • 7
5

I see many answers like try and error after searching about the issue, I got the following : it simply depends on three parameters and they have to be compatible

  1. Windows platform "x86,x64" you can change it from the CPU option of the visual studio or choose any CPU hence the install .net x framework should be compatible with the windows
  2. The target framework for the project (check the project target framework "right-click on the project and check target framework") if it is 5 so the enabled in the third parameter should be 5 or change this one but take care you should tell the other team members if you change it
  3. The Enabled framework go for tools and get tools and go for individuals component and chose the target framework the same as found in step 2 and press modify
mohamed saeed
  • 147
  • 1
  • 6
4

I had the same error. Remove "Microsoft.AspNetCore.All" from dependencies.

4

I have downgraded "Microsoft.AspNetCore.App" version and error gone .

shA.t
  • 16,580
  • 5
  • 54
  • 111
  • I recommend this way, when you see a warning message about *Not using this version of this package*; ;). – shA.t Mar 15 '20 at 08:48
4
  1. Deleting all bin folders of my solution
  2. building everything again did the trick for me

(.NET Core 3.1 VS 2019)

CodingYourLife
  • 7,172
  • 5
  • 55
  • 69
3

Faced this issue during xUnit testing. Downgrading nuget package "Microsoft.NET.Test.Sdk" to 15.9.0 worked for me

zed101
  • 193
  • 1
  • 2
  • 10
2

I got this error because of a Project reference pointing to a project, that did not exist anymore (was removed in merged git-commit). Solved it by right-clicking the project, then Edit Project File, delete the reference and save.

Frederik Struck-Schøning
  • 12,981
  • 8
  • 59
  • 68
2

I was trying to run a project that used net core 2.2 but I didn't have it, and there was no error(I had 1.1), so after installing the 2.2 using the "Visual Studio Installer" it worked like a charm. =)

David Castro
  • 1,773
  • 21
  • 21
  • 1
    This worked for me, just wen to the microsoft page, downloaded and installed the 2.2 net core version sdk and restarted visual studio, now works like a charm. – Dayán Ruiz Sep 27 '21 at 14:48
1

I restarted my Visual Studio instance in Admin mode and I was able to debug.

After closing Visual Studio I can now start in normal mode and debug as expected. I'm not sure what changed though.

Morgan Kenyon
  • 3,072
  • 1
  • 26
  • 38
1

I was missing a reference to AWSSDK.Core. After installing the specific version and re-starting VS2019 and rebuilding, the project ran fine.

Mike Upjohn
  • 1,251
  • 2
  • 16
  • 38
1

All of a sudden it stopped working. For me clean solution and re-build solution worked.

Anonymous Creator
  • 2,968
  • 7
  • 31
  • 77
1

I was getting a similar error with my project: The target process exited without raising a CoreCLR started event.

My startup project was targeting multiple frameworks: netstandard2.0;netcoreapp2.2

I fixed this issue by changing my target framework from netstandard2.0 to netcoreapp2.2 using the following stackoverflow directions: How to switch between target frameworks for .NET Core projects in Visual Studio

Josh Graham
  • 123
  • 6
1

Be sure to install the exact version of .net core that you want your project to run on

mattylantz
  • 312
  • 4
  • 10
1

I had this issue and finally tracked it down to doing a "publish" operation with a deployment mode of: "Self contained" That resulted in dropping all .NET runtime binaries in my bin directory. Where I think things got totally messed up is I have several solutions all using that same common bin directory, each build different exe's and dll's. Only one was for a self contained deployment as a test. I think that started mixing up some of the minor dlls for the .NET core and causing this issue. Once I purged all the dll's that were "not mine" and rebuilt things started working again. I'm using Visual Studio 2019 16.8.2 / .NET Core 3.1

I realize the original question is regarding .NET Core 2.2 but this question comes up first when searching for the main issue.

John Dyer
  • 2,316
  • 1
  • 21
  • 27
1

.Net Core 2.2 is required to be installed. I fixed when I added this in Visual Studio Installer.

Luke
  • 194
  • 3
  • 10
1

VS2019 16.7.1 ASP.Net Core 3.1

Our Nunit test projects that issued this error, only worked with a very select set of Nunit and Microsoft packages.

  • Microsoft.NET.Test.sdk - 16.5
  • Nunit - 3.12
  • Nunit3TestAdapter 3.16.1

But here's the catch, you have to go into c:\users\yourname\.nuget\packages and look for all three folders shown above. If you find any other version in those folders, delete it.

I found two versions in the Microsoft.NET.Test.SDK folder. I suspect the newer version was being loaded. Why? Because when I deleted it everything ran fine.

JWP
  • 6,672
  • 3
  • 50
  • 74
  • Update: 08/30/2021 Microsoft.NET.Test.Sdk V16.11.0 has worked in first test today. – JWP Aug 30 '21 at 22:09
1

A corrupt layout is also possible, had this happen myself. To fix, go to projpath\bin\x64\configtype\AppX, for example:

C:\Users\Foo\Documents\Visual Studio 2019\projectname\bin\x64\Debug\AppX

Delete everything here, rebuild and you're good to go.

1

Since I don't see it here yet, here's what worked for me. I have a UWP project, Win32 project, and Windows application packaging project in the same solution. Running the Win32 app using FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync was giving this message and not working.

What fixed it was changing a setting in the packaging project's project settings: Debug -> Debugger type -> Background task process: Native Only

miapuffia
  • 31
  • 4
1

I had same issue. Now in VS2022 you cannot download NetCore2.2. So just download and install NetCore 2.2 from microsoft dotnet website. https://dotnet.microsoft.com/en-us/download/dotnet/2.2

  • Thank you, I had the same problem, SDK 2.2.207 is not installed in vs2022. you can also go with the VS2022 modified meat. From here, you can upload the missing content (sdk, not supported contenct) by clicking the "individual component". – Onur Dikmen Jun 06 '22 at 06:49
1

This error occurred when I tried changing C# projects in my solution to use Docker and running it: Docker selected in Visual Studio run command

The error went away when I changed the C# projects back to use the Visual Studio's debug server and running it: Visual Studio debug server selected in Visual Studio run command

HappyGoLucky
  • 379
  • 3
  • 9
0

In the Test Explorer window of Visual Studio 2019, make sure that there are no references to any *.testsettings or *.runsettings files if you are not using them intentionally. I had referenced a *.testsettings file unintentionally, and that was causing the issue.

enter image description here

Fuzzy Analysis
  • 3,168
  • 2
  • 42
  • 66
0

For me, I'd just installed Visual Studio 2022 on a fresh installation of Windows 11. My project uses .Net 5, which wasn't installed by default (I only had .Net 6). I simply used the Visual Studio installer, modified my VS2022, selected Individual Components, and enabled .Net 5. Viola!

0

I started to get this error after updating Visual Studio from 2019 to 2022. It turned out that the project target framework was set to .Net Core 3.1, which was removed when I uninstalled VS2019, and the solution was to change it to .Net 6.0 which is the component I had selected during installation (Installing .Net Core 3.1 from the Visual Studio Installer should work as well).

To do so, right click on the project name and look for the "Target framework" option (my installation is in Spanish so that's what I presume it should say).

IAmAgainst
  • 23
  • 1
  • 2
0

I've encountered this issue multiple times, using VS 2017 and VS 2019 across .NET Core 2.1, 3.1 and 5.0.

There are many conditions that can cause this problem to occur:

Microsoft Update can install a version of .Net Core at any time, automatically and outside of your awareness and knowledge.

It can also change the installation of any .Net Core SDK version's installed components.

Your version of VS has to be compatible with the version of the .Net Core SDK that you have installed.

You must have all of the following components installed for this error to be resolved/pre-empted for .NET 5.0 (please check the dotnet 5.0 site for the compatibility list by versions).

Microsoft .NET SDK 5.0.408 which includes (the following below) must all be installed and listed in the control panel: .NET Core 5.0.17 Windows Desktop Runtime,.NET Runtime, Windows Server Hosting, Shared Framework

If any .NET Core 3.1 SDK are installed without your knowledge, you must uninstall it and repair your targeted .net core version's installation.

0

To me it happened after I rename the project name and also rename the AssemblyName.

I solved it removing hidden folder .vs and obj, both located inside project's directory. Then reload or reopen the project on VS.

I cant now debug with Any Cpu again.

CamiloVA
  • 651
  • 5
  • 11
0

I got this message while running an web application with script debugging enabled and got this message:

enter image description here

In the output tab, I got also the following 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 '[75680] dotnet.exe' has exited with code 2147516566 (0x80008096).

Solution for me:

Open the Visual Studio Installer, install the newest update. No windows restart needed in my situation. That was all. Simple.

As you can see from other answers: Solution could be different for everybody, but the problem has something to do with uninstalled things. The question is: What you are missing.

RuhrpottDev
  • 484
  • 5
  • 10