25

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?

riQQ
  • 9,878
  • 7
  • 49
  • 66
Joe
  • 6,773
  • 2
  • 47
  • 81
  • 1
    Try adding `**YOUR-OS-ID-HERE**-x64`. See https://learn.microsoft.com/en-us/dotnet/articles/core/rid-catalog for a list of OS specific identifiers – Tseng Apr 11 '17 at 19:14
  • @Joe struggeling with the same problem, could u fix it? – nik Apr 30 '17 at 02:24
  • @nik, x3ro's solution worked. Setting the runtime identifier to win7-x64 and targeting the right exe in the config. – Joe May 17 '17 at 09:35
  • Thx @Joe, tho in my case i was missing the x86 sdk (x64 was installed) of .net core. Still wondering why i got that error message... – nik May 17 '17 at 15:27

5 Answers5

21

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
x3ro
  • 226
  • 2
  • 2
  • Thanks, I had missed the "win7-x64" out of the program path and it was pointing to the older version in net461. Note, for anyone else reading this, that type "clr" had to be "coreclr". – Joe May 17 '17 at 09:35
10

after losing a day "what to do...'

  1. here were the steps I use the UPDATE to move to ver 3 because was giving me a "Old version is in use'

from ver 2 to ver 3

you need to run CMD as Administrator you can skip to step 3 if you do not have install it


choco upgrade azure-functions-core-tools-3
  1. I uninstall it
    choco uninstall azure-functions-core-tools-3

then

THE MOMENT OF TRUTH To install the 64-bit version, which allows you to debug, you can use the command


choco install azure-functions-core-tools-3 --params="'/x64:true'"

BAM worked

The solution is in the first comment

https://chocolatey.org/packages/azure-functions-core-tools-3#install

thanks Tyler Doerksen life saver!!!!

Valentin Petkov
  • 1,570
  • 18
  • 23
  • 1
    I can confirm too that this is a correct solution – gsscoder Apr 21 '22 at 07:34
  • 1
    Thank you for providing the solution!! It is working like a charm :D Thanks!!! What I was trying to do is debugging in VS code for my logic app. – wei Oct 05 '22 at 01:01
  • I don't remember answering this for someone but ... you are welcome :) – Tyler Jun 20 '23 at 21:33
7

Below worked for me:

  1. Go to Environment variables
  2. Select Edit for Path system variable
  3. Move C:\Program Files\dotnet\ entry up over C:\Program Files (x86)\dotnet\
  4. Click OK
  5. Close and start VS Code again.
Y. Khan
  • 101
  • 1
  • 3
2

I had to reinstall dependencies directly. If you used a package manager like chocolatey to install dependencies like 'azure-functions-core-tools' or 'dotnet core', you'll have to remove those from chocolatey and install directly.

heratyian
  • 414
  • 3
  • 13
0

If you are successfully installed dotnet core cli in your machine ...check the installation folder if it is installed in programfiles(x86) you installed 32 bit version of dotnet cli .c# extension unable to support debugging in 32bit version so uninstall dotnet cli 32 version try to install dotnet cli 64bit version.if you installed 64bit version 'dotnet' folder created inside 'programfiles' so now you are good to go

ABHISHEK N
  • 29
  • 3