gpt4 book ai didi

c# - 全新安装后测试 Hello World 代码时无法运行 "System.Windows.Forms application"

转载 作者:太空宇宙 更新时间:2023-11-04 11:46:24 27 4
gpt4 key购买 nike

我是 linux (Slackware 14.2) 用户,需要为我计算机上的工作项目安装 mono。安装 slackbuild 后,我运行了 https://www.mono-project.com/docs/getting-started/mono-basics/ 中的代码在我尝试按如下方式使用“System.Windows.Forms”之前效果很好:

using System;
using System.Windows.Forms;

public class HelloWorld : Form
{
static public void Main ()
{
Application.Run (new HelloWorld ());
}

public HelloWorld ()
{
Text = "Hello Mono World";
}
}

编译运行后得到:

$ mono hello.exe 

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.ThemeEngine' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.ThemeWin32Classic' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Drawing.KnownColors' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception. ---> System.DllNotFoundException: libgdiplus.so.0
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000ab] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x0001a] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Black () [0x00000] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.ThemeEngine..cctor () [0x0002f] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.Control..ctor () [0x000e4] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00014] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.ContainerControl..ctor () [0x0000e] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.Form..ctor () [0x00012] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at HelloWorld..ctor () [0x00000] in <ebd84f70eef34e1bac9228a36ebc3550>:0
at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
at HelloWorld.Main () [0x00001] in <ebd84f70eef34e1bac9228a36ebc3550>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.ThemeEngine' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.ThemeWin32Classic' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Drawing.KnownColors' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception. ---> System.DllNotFoundException: libgdiplus.so.0
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000ab] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x0001a] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Black () [0x00000] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.ThemeEngine..cctor () [0x0002f] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.Control..ctor () [0x000e4] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00014] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.ContainerControl..ctor () [0x0000e] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.Form..ctor () [0x00012] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at HelloWorld..ctor () [0x00000] in <ebd84f70eef34e1bac9228a36ebc3550>:0
at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
at HelloWorld.Main () [0x00001] in <ebd84f70eef34e1bac9228a36ebc3550>:0

我有没有做错(或没有​​做)的事情?

最佳答案

没有注意到我安装了 32 位库。现在完美运行。
谢谢Stefan Becker .

关于c# - 全新安装后测试 Hello World 代码时无法运行 "System.Windows.Forms application",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57550630/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com