Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I don't have VS 2017, and I'll be building a web front-end in VS Code anyway so I want to use VS Code.

Until .NET Standard 2.0 comes out, our libraries are also in 4.6.1, so I'm targetting 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 starter app. I can build and run with dotnet build and dotnet run. I've also got the latest ms-vscode.csharp extension 1.8.1.

However, when I try attaching or debugging this application with VS Code I get the error

Failed to attach to process: Only 64-bit processes can be debugged

Even running from console, then attaching with the very simple configuration:

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

And selecting the process fails with this error. I've tried building the exe targeting x64 with:

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

But it produces the same error. Anyone know a fix? It seems to be because I'm targetting net461, does debugging .Net Core not support targeting other frameworks?

like image 488
Joe Avatar asked Apr 11 '17 10:04

Joe


People also ask

How do I Debug a .NET core code in Visual Studio?

Open the Debug view by selecting the Debugging icon on the left side menu. Select the green arrow at the top of the pane, next to . NET Core Launch (console). Other ways to start the program in debugging mode are by pressing F5 or choosing Run > Start Debugging from the menu.

Is VS code good for debugging?

One of the key features of Visual Studio Code is its great debugging support. VS Code's built-in debugger helps accelerate your edit, compile, and debug loop.


1 Answers

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

Modify your launch.json file:

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

To target x64, modify your .csproj file like so:

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

An example program path after specifying the runtime id:

"program" : ${workspaceRoot}/src/bin/Debug/net461/win7-x64/example.exe 
like image 139
x3ro Avatar answered Sep 23 '22 17:09

x3ro