Unable to debug C# console application
Steps to reproduce
- Create new Console Application project in VS 2019 with notable config options:
<OutputType>WinExe</OutputType>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
- Open it with VS Code
- Configure task.json and launch.json, so that it builds and launches
- Place a reachable breakpoint
Expected behavior
Execution stops at breakpoint.
Actual behavior
Execution runs past the breakpoint.
Logs
OmniSharp log
OmniSharp server started. Path: c:\Users\Yury.vscode\extensions\ms-dotnettools.csharp-1.23.5.omnisharp\1.37.3\OmniSharp.exe PID: 17052
Starting OmniSharp on Windows 6.2.9200.0 (x64) info: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet info: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 2 MSBuild instance(s) 1: Visual Studio Community 2019 16.7.30523.141 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin" 2: StandAlone 16.8.0 - "c:\Users\Yury.vscode\extensions\ms-dotnettools.csharp-1.23.5.omnisharp\1.37.3.msbuild\Current\Bin" info: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: Visual Studio Community 2019 16.7.30523.141 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin" info: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in 'c:\TheApp'. info: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files info: OmniSharp.MSBuild.ProjectSystem Detecting projects in 'c:\TheApp\TheApp.sln'. info: OmniSharp.MSBuild.ProjectManager Queue project update for 'c:\TheApp\TheApp.csproj' info: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in 'c:\TheApp'. info: OmniSharp.Script.ScriptProjectSystem Could not find any CSX files info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 info: OmniSharp.MSBuild.ProjectManager Loading project: c:\TheApp\TheApp.csproj info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110 info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140 info: OmniSharp.WorkspaceInitializer Configuration finished. info: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location 'c:\TheApp' on host 16280. info: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'c:\TheApp\TheApp.csproj'. info: OmniSharp.MSBuild.ProjectManager Adding project 'c:\TheApp\TheApp.csproj' info: OmniSharp.MSBuild.ProjectManager Update project: TheApp
C# log
Environment information
VSCode version: 1.50.1 C# Extension: 1.23.5
Dotnet Information
.NET Core SDK (reflecting any global.json): Version: 3.1.402 Commit: 9b5de826fdRuntime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.402\
Host (useful for support): Version: 3.1.8 Commit: 9c1330dedd
.NET Core SDKs installed: 3.1.402 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions
| Extension | Author | Version |
|---|---|---|
| Bookmarks | alefragnani | 11.4.0 |
| cmake-tools | ms-vscode | 1.5.1 |
| code-spell-checker | streetsidesoftware | 1.9.2 |
| csharp | ms-dotnettools | 1.23.5 |
| customize-ui | iocave | 0.1.49 |
| goto-next-previous-member | mishkinf | 0.0.5 |
| monkey-patch | iocave | 0.1.11 |
| prevent-brackets-duplication | mouse-frontend | 0.0.3 |
| theme-monokai-pro-vscode | monokai | 1.1.17 |
| toggle | rebornix | 0.0.1 |
| vscode-solution-explorer | fernandoescolar | 0.3.11 |
| xml | DotJoshJohnson | 2.5.1 |
| xml-format | mikeburgh | 1.0.2 |
Additional information
-
When I hover cursor over the breakpoint during the execution, appears a pop-up with the following message:
No symbols have been loaded for this document. -
System.Console.WriteLine(System.Diagnostics.Debugger.IsAttached);prints False. -
configurations.logging.moduleLoadset to true, however, no messages about module loading appear. -
I am able to debug other C# projects in VS Code
-
I am able to debug this project in VS 2019.
At the start of debug session in the VS 2019 following messages appear:
'TheApp.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
'TheApp.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\TheApp\bin\Debug\TheApp.exe'. Symbols loaded.
'TheApp.exe' (CLR v4.0.30319: TheApp.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'.
'TheApp.exe' (CLR v4.0.30319: TheApp.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'.
'TheApp.exe' (CLR v4.0.30319: TheApp.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'.
'TheApp.exe' (CLR v4.0.30319: TheApp.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'.
'TheApp.exe' (CLR v4.0.30319: TheApp.exe): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Remote Debugger\x64\Runtime\Microsoft.VisualStudio.Debugger.Runtime.dll'.
'TheApp.exe' (CLR v4.0.30319: TheApp.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'.
'TheApp.exe' (CLR v4.0.30319: TheApp.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'.
@YuryTheName This is because you need to change type in your launch.json from coreclr to clr. More info: https://github.com/OmniSharp/omnisharp-vscode/wiki/Desktop-.NET-Framework
Awesome! Thanks a lot! I couldn't imagine that would this easy!