C
C#2y ago
Syrup

❔ Why does this program close?

23 Replies
Syrup
SyrupOP2y ago
Why does this program close on me without touching any buttons? msb1009?
Buddy
Buddy2y ago
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.
Syrup
SyrupOP2y ago
I did. It seems to work in the terminal, but will not pop up while debugging. probably a good idea lol
ZacharyPatten
ZacharyPatten2y ago
How are you debugging it?
Syrup
SyrupOP2y ago
By clicking run or f5
ZacharyPatten
ZacharyPatten2y ago
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
Syrup
SyrupOP2y ago
It works in the integrated terminal but not in the external
ZacharyPatten
ZacharyPatten2y ago
What do you mean by "it works" In general what i'm trying to suggest is that you never use the integrated terminal
Syrup
SyrupOP2y ago
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
ZacharyPatten
ZacharyPatten2y ago
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.
Syrup
SyrupOP2y ago
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?
Syrup
SyrupOP2y ago
Timestamp: 2:00
ZacharyPatten
ZacharyPatten2y ago
share your launch.json file
ZacharyPatten
ZacharyPatten2y ago
ZacharyPatten
ZacharyPatten2y ago
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
Syrup
SyrupOP2y ago
{ "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
Syrup
SyrupOP2y ago
Alright I will swtich programs but let me know if we can fix this please!!! FIXED IT!!!
Ghost4Man
Ghost4Man2y ago
false VS Code Debug Console does not allow input integrated terminal is fine https://aka.ms/VSCode-CS-LaunchJson-Console
ZacharyPatten
ZacharyPatten2y ago
"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
Ghost4Man
Ghost4Man2y ago
which ones?
ZacharyPatten
ZacharyPatten2y ago
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
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server