Skip to content

Console.KeyAvailable throws when input isn't redirected on Windows 7 x86  #43015

Closed as not planned

Description

@ViktorHofer
[xUnit.net 00:00:03.88]     ReadKey.KeyAvailable [FAIL]
[xUnit.net 00:00:03.88]       System.InvalidOperationException : Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek.
[xUnit.net 00:00:03.88]       Stack Trace:
[xUnit.net 00:00:03.89]         /_/src/libraries/System.Console/src/System/ConsolePal.Windows.cs(278,0): at System.ConsolePal.get_KeyAvailable()
[xUnit.net 00:00:03.89]         /_/src/libraries/System.Console/src/System/Console.cs(153,0): at System.Console.get_KeyAvailable()
[xUnit.net 00:00:03.89]         /_/src/libraries/System.Console/tests/ReadKey.cs(21,0): at ReadKey.KeyAvailable()

Additional logging:

 fileTypeOutput 'input': 2
 IsInputHandleRedirected: False

The docs state that fileType 2 means:

The specified file is a character file, typically an LPT device or a console.

I would assume that in such a case an InvalidOperationException shouldn't happen. Also this seems to be specific to Windows 7 x86.

cc @eiriktsarpalis

Activity

  1. added this to the Future milestone on Oct 4, 2020
  2. added
    untriaged
    on Oct 4, 2020
  3. removed this from the Future milestone on Oct 4, 2020
  4. added this to the Future milestone on Oct 29, 2020
  5. removed
    untriaged
    on Oct 29, 2020
  6. adamsitnik commented on Jul 7, 2022

    @adamsitnik
    Member
  7. ghost locked as resolved and limited conversation to collaborators on Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions