23 Replies
Why does this program close on me without touching any buttons?
msb1009?
Did you save the file?
The ● next to file name means it's unsaved
Also I would not recommend Visual Studio Code for beginners, as it's a lot of manual work
As well as ghost errors (false errors)
I highly recommend Visual Studio if Windows.
If Mac or Linux then I recommend Jetbrains Rider.
I did. It seems to work in the terminal, but will not pop up while debugging.
probably a good idea lol
How are you debugging it?
By clicking run or f5
Are you using the integrated terminal in visual studio code or an external terminal?
Because the integrated terminal doesn't support A lot of the basic functions you'd expect it to
It works in the integrated terminal but not in the external
What do you mean by "it works"
In general what i'm trying to suggest is that you never use the integrated terminal
My problem is that the program automatically closes without me pressing any buttons, but I thought the Console.ReadKey(); line prevents that until I click a button/type
It will. But it depends on what's going on. It's possible that you aren't running the current code that you're looking at. It's also possible that visual studios codes integrated terminal can't handle input.
I am currently watching a video and following it step by step, and it seems to work for the guy but not me. How do I know im running the right code?
Brackeys
YouTube
How to Program in C# - BASICS (E01)
Let's write our first code in C#!
► SIGN UP FOR JASON'S COURSES: https://game.courses/gamearch/
● Watch the Getting Started Video: https://youtu.be/N775KsWQVkw
● My Solution to the Challenge: https://forum.brackeys.com/discussion/746/brackeys-solution-to-c-tutorial-01-challenge
https://forum.brackeys.com/discussion/746/brackeys-answer-to-c-tu...
Timestamp: 2:00
share your launch.json file
again if you try to use the integrated terminal... it fails
why? cause the integrated terminal in Visual Studio Code does not allow input
only output
that dude in the youtube video is using the external terminal setting
so you need to be using external terminal too
which is something you set in the
launch.json
file
but as was already mentioned... you really should just use Visual Studio
you will not run into these kinda of issues{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net7.0/Program.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "externalTerminal",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
GitHub
omnisharp-vscode/debugger-launchjson.md at master · OmniSharp/omnis...
Official C# support for Visual Studio Code (powered by OmniSharp) - omnisharp-vscode/debugger-launchjson.md at master · OmniSharp/omnisharp-vscode
GitHub
omnisharp-vscode/debugger-launchjson.md at master · OmniSharp/omnis...
Official C# support for Visual Studio Code (powered by OmniSharp) - omnisharp-vscode/debugger-launchjson.md at master · OmniSharp/omnisharp-vscode
Alright I will swtich programs but let me know if we can fix this please!!!
FIXED IT!!!
false
VS Code Debug Console does not allow input
integrated terminal is fine
https://aka.ms/VSCode-CS-LaunchJson-Console
"internalConsole" (default) : the target process's console output (stdout/stderr) goes to the VS Code Debug Console. This is useful for executables that take their input from the network, files, etc. But this does NOT work for applications that want to read from the console (ex: Console.ReadLine).fair I said "integrated terminal" when I should have said "internal console" but the issue still remains that if you don't change the default terminal you cannot read input and even if you use the integrated it still doesn't fully support the common console operations
which ones?
it used to be a lot of commands like
WindowWidth
, SetCursorPosition
, BufferWidth
, Beep
...
but testing it now... it looks like most of them are working in the integrated terminal now. It was several years ago when I last tested the integrated terminal. It looks like they made a lot of progress 🙂
however, it is still annoying that when you launch a debugging session it opens to the Output
rather than the Terminal
tab
so that might confuse new devs
whereas the external terminal will launch a new console in a seperate window (at least in windows) making it hard to miss
also, if you want your console to be maximized/large... using the integrated terminal still isn't ideal
Alternatively add "internalConsoleOptions": "neverOpen" to make it so that the default foreground tab is the terminal tab.need to try that setting
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.