使用VS Code进行.NET Core调试-“只能调试64位进程" [英] .NET Core debugging with VS Code - "Only 64-bit processes can be debugged"

查看:646
本文介绍了使用VS Code进行.NET Core调试-“只能调试64位进程"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有VS 2017,无论如何我都会在VS Code中构建一个Web前端,所以我想使用VS Code.

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.

直到.NET Standard 2.0出现,我们的库也位于4.6.1中,所以我的目标是.NET Core csproj中的net461:

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>

该项目是最简单的dotnet new webapi入门应用程序.我可以使用dotnet builddotnet run进行构建和运行.我还拥有最新的ms-vscode.csharp扩展1.8.1.

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.

但是,当我尝试使用VS Code附加或调试此应用程序时,出现错误消息

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

无法附加到进程:只能调试64位进程

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}"
}

选择过程失败,并显示此错误.我尝试用以下方式构建针对x64的exe文件:

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>

但是会产生相同的错误.有人知道解决方法吗?似乎是因为我针对的是net461,调试.Net Core是否不支持针对其他框架?

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?

推荐答案

ms-vscode.csharp扩展名

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

修改您的launch.json文件:

Modify your launch.json file:

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

要定位x64,请按如下所示修改.csproj文件:

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

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

指定运行时ID后的示例程序路径:

An example program path after specifying the runtime id:

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

这篇关于使用VS Code进行.NET Core调试-“只能调试64位进程"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆