Omnisharp-vscode: Debug Console window cannot accept Console.ReadLine() input during debugging

Created on 17 Dec 2016  路  16Comments  路  Source: OmniSharp/omnisharp-vscode

_From @LiangZugeng on December 17, 2016 4:21_

  • VSCode Version: 1.8.0
  • OS Version: Win10 x64

Steps to Reproduce:

  1. Create a new .net core cli app using "dotnet new"
  2. Open the folder using VS code
  3. Add two lines of code in Program.cs
    string a = Console.ReadLine();
    Console.WriteLine(a);
  4. Switch to VS code debug window and start debugging
  5. Debug Console window shows, and displays the first "Hello, World." output, and stops on the line of Console.ReadLine(), enter anything in the Debug Console and press Enter will be given err message of "Unable to perform this action because the process is running."
    untitled

_Copied from original issue: Microsoft/vscode#17446_

Most helpful comment

_From @kieferrm on December 17, 2016 14:50_

The debug console is output only. The input field you see is for inspecting the environment available at a given stack frame. In your launch config you can specify what console your program should use. Set the console property to externalTerminal. internalTerminal should work as well.

All 16 comments

_From @kieferrm on December 17, 2016 14:50_

The debug console is output only. The input field you see is for inspecting the environment available at a given stack frame. In your launch config you can specify what console your program should use. Set the console property to externalTerminal. internalTerminal should work as well.

_From @kieferrm on December 17, 2016 14:51_

@weinand I think we should look for a way to make more explicit that the input field is inspection only.

_From @LiangZugeng on December 17, 2016 15:5_

@kieferrm thank you for your reply, below is my launch.json file and I didn't find a property called console, only externalConsole, when it's set to true the keyboard input can be accepted but a new console opened for the debugging, I cannot find internalTerminal configuration option. I tried to switch to the Integrated Terminal while the app waits for the keyboard input but it's the command line there waiting for a command.

Anyway I still wonder if I can debug the app within the Visual Studio Code UI while making Console.ReadLine() to work correctly.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceRoot}\\bin\\Debug\\netcoreapp1.1\\hwapp.dll",
            "args": [],
            "cwd": "${workspaceRoot}",
            "externalConsole": false,
            "stopAtEntry": false,
            "internalConsoleOptions": "openOnFirstSessionStart"
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command.pickProcess}"
        }
    ]
}

If you can get a modified launch.json to solve my problem that will be great.

@LiangZugeng you are using the coreCLR debugger. I'll move this issue to the corresponding repository.

@LiangZugeng If you want to make an application that reads from the console then you want to change your lanch.json so that console is set to integratedTerminal (or externalTerminal).

More information: https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window

When I use the Python debugger in the Visual code, I'm unable to take input value form debug console. When I set the console property to integrated or external terminal, I'm UNABLE to inspect objects (able take input value from console).
Is there anyway to input values and also inspect objects.

@madhu150894 it sounds like your question is about the Python debugger. If so, you are asking in the wrong repo -- this is the C# debugger. Also I would generally suggest opening new issues instead of commenting on closed ones.

@gregg-miskelly It works for me with integratedTerminal. Thank you.

@aeciolevy you want to change the console option now. Here is the note that gets dropped in our launch.json generator:

            // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
            "console": "internalConsole",

Here is the link so it is easy to click :)

https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window

"integratedTerminal" and "externalTerminal" are the correct values that make this work now in v1.24.1 of VSCode.

"console": "integratedTerminal"
or
"console": "externalTerminal"

If you use console: integratedTerminal, put this setting to :
"internalConsoleOptions": "neverOpen"
That ll avoid the auto switch Terminal tab to Debug Console tab at start.

_From @kieferrm on December 17, 2016 14:50_

The debug console is output only. The input field you see is for inspecting the environment available at a given stack frame. In your launch config you can specify what console your program should use. Set the console property to externalTerminal. internalTerminal should work as well.

'internalTerminal' have to be 'integratedTerminal'.

Having trouble with my launch.json

   "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${fileDirname}",
            "console": "integratedTerminal",
            "env": {},
            "args": [],
        }
    ]
}

Complains that property console is not allowed...

@daxmc99 this issue is specific to the C# debugger. If you are having issues with the 'go' debugger, I believe you want to report them here.

@gregg-miskelly Thank you, seems this is a known issue https://github.com/Microsoft/vscode-go/issues/843

Was this page helpful?
0 / 5 - 0 ratings