我正在尝试在Linux上的Rider中编译C#Hello World应用程序。 当我尝试运行应用程序时,我会遇到以下异常:
Unhandled Exception:
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) [0x00028] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0005f] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.TermInfoDriver..ctor (System.String term) [0x00055] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.ConsoleDriver..cctor () [0x0004d] in <a84b655e5e6a49ee96b338ec792f5580>:0
--- End of inner exception stack trace ---
at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.Console..cctor () [0x0008e] in <a84b655e5e6a49ee96b338ec792f5580>:0
--- End of inner exception stack trace ---
at TestCaseApp.Program.Main (System.String[] args) [0x00001] in <662667bfa1e4443ea031df076247d2d3>:0
[ERROR] FATAL UNHANDLED EXCEPTION: 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) [0x00028] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0005f] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.TermInfoDriver..ctor (System.String term) [0x00055] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.ConsoleDriver..cctor () [0x0004d] in <a84b655e5e6a49ee96b338ec792f5580>:0
--- End of inner exception stack trace ---
at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in <a84b655e5e6a49ee96b338ec792f5580>:0
at System.Console..cctor () [0x0008e] in <a84b655e5e6a49ee96b338ec792f5580>:0
--- End of inner exception stack trace ---
at TestCaseApp.Program.Main (System.String[] args) [0x00001] in <662667bfa1e4443ea031df076247d2d3>:0
我正在使用Antergos(Linux)和JetBrains Rider 2017.3.1 构建#RD-173.3994.2442 我使用的是Mono 5.4.1.7-2
我做了一些关于这个bug的研究,我找到了:
https://github.com/mono/mono/issues/6752#issuecomment-365212655
Mono compiler // Terminal emulator issue
这些主题中提到的所有内容都没有帮助我解决这个问题。我该怎么办?
答案 0 :(得分:29)
您没有按照该页面上的说明进行操作吗?您需要将TERM
环境变量设置为xterm
作为修复:
export TERM=xterm
然后用以下方式验证它是否已更改:
echo $TERM
答案 1 :(得分:3)
确切的意思是:“我想运行您的脚本,但是您需要指定要我使用的终端”
在GoG版本的Stardew Valley中,相关脚本为:./start.sh 启动它会导致上述错误。 如果相反:
export 'TERM=roxterm' && ./start.sh
然后它可以工作,因为我的系统上安装了roxterm终端,脚本可以使用它来执行。我所知道的是Ubuntu中的全局参数,它告诉脚本使用此参数,除非是:Default Applications
看看脚本的片段,原来是:
run_game() {
echo "Running ${GAME_NAME}"
cd game
chmod +x *
./"StardewValley"
}
更正为近似值:
run_game() {
echo "Running ${GAME_NAME}"
cd game
chmod +x *
export 'TERM=roxterm' && ./"StardewValley"
}
后一种解决方案可与应用程序启动器一起使用,因此是优越的。