Mono: System.TypeInitializationException: The type initializer for 'System.Console' threw an exception

Created on 25 Apr 2018  路  2Comments  路  Source: mono/mono

Steps to Reproduce

  1. Try to use Console class
  2. Build file

Current Behavior

The type initializer for 'System.Console' threw an exception.

Expected Behavior

Successfully compile file and print result in the Terminal

On which platforms did you notice this

[ ] macOS
[x ] Linux
[ ] Windows

Version Used:
5.10.0

Stacktrace

System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542
  at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x00018] in /build/mono/src/mono/mcs/class/corlib/System/TermInfoReader.cs:122
  at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0005f] in /build/mono/src/mono/mcs/class/corlib/System/TermInfoReader.cs:97
  at System.TermInfoDriver..ctor (System.String term) [0x00055] in /build/mono/src/mono/mcs/class/corlib/System/TermInfoDriver.cs:164
  at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in /build/mono/src/mono/mcs/class/corlib/System/ConsoleDriver.cs:73
  at System.ConsoleDriver..cctor () [0x0004d] in /build/mono/src/mono/mcs/class/corlib/System/ConsoleDriver.cs:57
  --- End of inner exception stack trace ---
  at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00000] in /build/mono/src/mono/mcs/class/corlib/System/Console.cs:136
  at System.Console..cctor () [0x0008e] in /build/mono/src/mono/mcs/class/corlib/System/Console.cs:130
  --- End of inner exception stack trace ---
  at test.MainClass.Main (System.String[] args) [0x00001] in /home/bartek/Projects/test/test/Program.cs:10

**

echo $TERM

outputs: xterm-256color

Also getting same error when typing "msbuild" in the terminal

Most helpful comment

A workaround is to set the environment variable TERM=xterm (thanks https://github.com/mono/mono/issues/6752#issuecomment-365212655)

TERM=xterm pdfmod foo.pdf

(works for me on Debian testing)

All 2 comments

Duplicate of #6752

@Fensi3321 please install the latest Stable 5.10.xx mono package from http://www.mono-project.com/download/stable/#download-lin this bug is fixed in recent stable releases (5.10.1.145 at a minimum).

See https://github.com/mono/mono/issues/6752#issuecomment-382737904

A workaround is to set the environment variable TERM=xterm (thanks https://github.com/mono/mono/issues/6752#issuecomment-365212655)

TERM=xterm pdfmod foo.pdf

(works for me on Debian testing)

Was this page helpful?
0 / 5 - 0 ratings