Issue
Actually, the problem I'm having right now is exactly same as href="https://stackoverflow.com/questions/46901071/readkey-invalidoperationexception-application-does-not-have-a-console">ReadKey InvalidOperationException application does not have a console.
But the all provided solutions in that question don't work for me. The reason they don't work is I can neither add "console": "integratedTerminal"
nor "internalConsole":true
(These options available in VS Code official page as well). But I've searched a lot but there is nothing about these.
VS Code warns as "property console/internalConsole isn't allowed."
My current .json configuration file is as following:
{
"version": "0.2.0",
"configurations": [
{
"name": "C#: Events Example",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/Event/Event.csproj",
"launchConfigurationId": "TargetFramework=;Microsoft.NETCore.App"
}
]
}
As a summary, how can I use terminal to debug C# app in VS Code in Linux?
Solution
The VSCode C# Extension (previously OmniSharp) brings in with it a configuration "type": "coreclr"
. This in turn brings the console
property needed to tell VSCode where to redirect stdin/out
.
We also need to point to the produced .dll
instead of the .csproj
. The config will look something like the following:
"name": "Launch Me",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/<target-framework>/<project-name.dll>",
"console": "integratedTerminal" //or internalConsole, or externalTerminal
The complete documentation is here. An example of a functional launch.json
for C# can be seen here.
Answered By - NPras Answer Checked By - David Goodson (WPSolving Volunteer)