Debugging .NET Core with VS Code - "Only 64-bit processes can be debugged"

I do not have VS 2017, and I will build a web interface in VS Code anyway, so I want to use VS Code.

Until .NET Standard 2.0 appears, our libraries are also in 4.6.1, so I am targeting net461 in my .NET Core csproj:

<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net461</TargetFramework> </PropertyGroup> <ItemGroup> <Folder Include="wwwroot\" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" /> </ItemGroup> </Project> 

The project is the simplest dotnet new webapi for beginners. I can build and run with dotnet build and dotnet run . I also got the latest ms-vscode.csharp 1.8.1 extension.

However, when I try to connect or debug this application using VS Code, I get an error

Failed to connect to the process: only 64-bit processes can be debugged

Even from the console, and then with a very simple configuration:

 { "name": ".NET Core Attach", "type": "coreclr", "request": "attach", "processId": "${command:pickProcess}" } 

And the process selection with this error ends. I tried creating exe targeting on x64 with:

 <PropertyGroup> <TargetFramework>net461</TargetFramework> <Platform>x64</Platform> </PropertyGroup> 

But he makes the same mistake. Does anyone know a fix? It seems because I'm aiming at net461, debugging .Net Core doesn't support targeting to other frameworks?

+11
source share
3 answers

Version 1.9.0 of the ms-vscode.csharp extension has added desktop CLR support.

Modify launch.json file:

 "type" : "clr", "program" : "path to x64 version of the executable.exe" 

To target x64, edit the .csproj file as follows:

 <PropertyGroup> <TargetFramework>net461</TargetFramework> <RuntimeIdentifier>win7-x64</RuntimeIdentifier> </PropertyGroup> 

An example of a program path after specifying a runtime identifier:

 "program" : ${workspaceRoot}/src/bin/Debug/net461/win7-x64/example.exe 
+11
source

Below worked for me:

  1. Go to environment variables
  2. Select Modify for the Path system variable.
  3. Move C: \ Program Files \ dotnet \ entry up above C: \ Program Files (x86) \ dotnet \
  4. Click OK
  5. Close and run VS Code again.
+1
source

I had to reinstall dependencies directly. If you used a package manager, such as chocolatey, to install dependencies such as "azure-functions-core-tools" or "dotnet core", you would have to remove them from Chocolatey and install it directly.

0
source

Source: https://habr.com/ru/post/1266584/


All Articles