-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.InvalidOperationException: 'Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read. #80695
Comments
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsDescriptionI'm having the follow error when I resize the console height to zero or almost zero and pointing the mouse to the available console space:
This is happening on Reproduction StepsTo test this issue please clone the https://github.com/gui-cs/Terminal.Gui repo and run the Expected behaviorI expected the console doesn't crash if height is equal or almost equal to zero. With almost zero I mean when the height is less than one and greater than zero. If it can't read with this size then it must check first for its size and not try to read any keystroke or mouse movements. Actual behaviorThe console really crash and disappear from the desktop, causing the errors already mentioned and others like pipe error. Regression?No response Known WorkaroundsNo response ConfigurationNet6.0, Net7.0 Other informationNo response
|
I think I discover the cause of this error when resizing the height to 0. I also submitted a PR gui-cs/Terminal.Gui#2294, after I found what was causing an error on |
Tagging subscribers to this area: @dotnet/area-system-console Issue DetailsDescriptionI'm having the follow error when I resize the console height to zero or almost zero and pointing the mouse to the available console space:
This is happening on Reproduction StepsTo test this issue please clone the https://github.com/gui-cs/Terminal.Gui repo and run the Expected behaviorI expected the console doesn't crash if height is equal or almost equal to zero. With almost zero I mean when the height is less than one and greater than zero. If it can't read with this size then it must check first for its size and not try to read any keystroke or mouse movements. Actual behaviorThe console really crash and disappear from the desktop, causing the errors already mentioned and others like pipe error. Regression?No response Known WorkaroundsNo response ConfigurationNet6.0, Net7.0 Other informationNo response
|
Currently this scenario is not supported, as runtime/src/libraries/System.Console/src/System/Console.cs Lines 419 to 429 in bd84336
Could you provide full stack trace? This error most likely comes from native windows sys-call, but we need to verify that to be 100% sure that it's by design and caused by the OS. |
Thanks for your feedback. Actually on
But there many |
Description
I'm having the follow error when I resize the console height to zero or almost zero and pointing the mouse to the available console space:
System.InvalidOperationException: 'Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.'
This is happening on
Windows
andWSL
usingcmd
,pwsh
andconhost
. As I'm reading escape sequences fromConsole.ReadKey (true)
in a console with a height equal to zero causes theSystem.Console.dll
crash. The problem is I can't force resizing the console. Do I still need to using for Windows the Win32 API Console by enablingENABLE_VIRTUAL_TERMINAL_PROCESSING
to be able to use escape sequences or doesSystem.Console
allows that feature? Another question is many escape sequences request are not available inWindows
andWSL
, is there any configuration I can use or is a limitation?Reproduction Steps
To test this issue please clone the https://github.com/gui-cs/Terminal.Gui repo and run the
UICatalog
project with the argument-usc
, which will use theNetDriver
using theSystem.Console
. Thanks.Expected behavior
I expected the console doesn't crash if height is equal or almost equal to zero. With almost zero I mean when the height is less than one and greater than zero. If it can't read with this size then it must check first for its size and not try to read any keystroke or mouse movements.
Actual behavior
The console really crash and disappear from the desktop, causing the errors already mentioned and others like pipe error.
Regression?
No response
Known Workarounds
No response
Configuration
Net6.0, Net7.0
OS: Windows 11 Pro Version: 22H2 Compilation: 22621.1105
Architecture: x64
Other information
No response
The text was updated successfully, but these errors were encountered: