Skip to content

Exception when running Minecraft Console Client as a script #8

Open

Description

@breadbyte

When starting MCC through a script / redirected input, the following exception occurs:

Unhandled exception. System.TypeInitializationException: The type initializer for 'ConsoleInteractive.InternalContext' threw an exception.
 ---> System.IO.IOException: The handle is invalid.
   at System.ConsolePal.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
   at System.Console.get_BufferWidth()
   at ConsoleInteractive.InternalContext..cctor() in C:\mcc-repos\Minecraft-Console-Client\ConsoleInteractive\ConsoleInteractive\ConsoleInteractive\InternalContext.cs:line 14
   --- End of inner exception stack trace ---
   at ConsoleInteractive.ConsoleBuffer.DrawPrefix() in C:\mcc-repos\Minecraft-Console-Client\ConsoleInteractive\ConsoleInteractive\ConsoleInteractive\ConsoleBuffer.cs:line 200
   at ConsoleInteractive.ConsoleReader.KeyListener(Object cancellationToken) in C:\mcc-repos\Minecraft-Console-Client\ConsoleInteractive\ConsoleInteractive\ConsoleInteractive\ConsoleReader.cs:line 86
   at System.Threading.Thread.StartCallback()

The prefix is then not drawn at this point.

Activity

  1. breadbyte commented on Aug 10, 2022

    @breadbyte
    OwnerAuthor

    The error here is that GetBufferWidth is returning an invalid handle.

    Checking if the console input is redirected using Console.IsInputRedirected may be useful for creating code paths for when input is redirected.

    This might require major changes in the way we handle printing to the console if GetBufferWidth and/or GetBufferLength is inaccessible.

  2. self-assigned this
    on Aug 26, 2022
  3. breadbyte commented on Dec 6, 2022

    @breadbyte
    OwnerAuthor

    Found out that running a debugging session through VS Code also triggers this.

    Useful, since we don't have to fire up a docker instance for testing.

    We could make a separate handler in MCC- this requires us to expose a IsConsoleInteractive property or something similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions