HelloWorld由Windows .NET成功启动,但未由MONO成功启动

Gen*_*нин 4 .net c# mono winforms

我使用以下命令在我的64位Windows 7上安装了mono:

在目录中(路径中没有空格)根据Jim Gomes的建议改变了

成功运行前两个示例

  • 控制台Hello World
  • Gtk #Hello World

来自Mono Basics的文章.

但是三维示例"WinForms Hello World"编译时没有错误,并且从Windows(通过双击Windows资源管理器)成功运行但运行:

mono hello.exe
Run Code Online (Sandbox Code Playgroud)

从"Mono-3.2.3命令提示符"窗口生成下面列出的错误(请注意,前两个示例包括第二个示例的窗口是从命令提示符调用成功启动的mono ...)

有什么问题以及如何克服它?

更新
根据上面提到的文章"单声道基础知识"我编写了三维示例"Winforms Hello World" gmcs hello.cs -pkg:dotnet.

顺便说一下,dotnet包裹在哪里?
它在同名目录中吗?dotnet在Mono-3.2.3目录下我没有一个具有这个名字的单一目录

mono hello.exe从"Mono-3.2.3命令提示符" 运行产生的错误

Unhandled Exception:
System.TypeInitializationException: 
An exception was thrown by the type initializer for 
System.Windows.Forms.WindowsFormsSynchronizationContext 
---> System.TypeInitializationException: 
An exception was thrown by the type initializer for 
System.Windows.Forms.ThemeEngine ---> System.TypeInitializationException: 
An exception was thrown by the type initializer for 
System.Windows.Forms.ThemeWin32Classic 
---> System.TypeInitializationException: 
An exception was thrown by the type initializer for System.Drawing.KnownColors 
---> System.TypeInitializationException: 
An exception was thrown by the type initializer for System.Drawing.GDIPlus 
---> System.DllNotFoundException: /tmp/install/lib/libgdiplus.so at 
 (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup 
 (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unk
nown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:
0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x0
0000] in <filename unknown>:0
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000]
 in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unkn    own>:0
  at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unkno    wn>:0
  at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0
  at HelloWorld..ctor () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
  at HelloWorld.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: 
  An exception was thrown by the type initializer for  
  System.Windows.Forms.WindowsFormsSynchronizationContext 
     ---> System.TypeInitializationException: 
      An exception was thrown by the type initializer for
      System.Windows.Forms.ThemeEngine 
      ---> System.TypeInitializationException: 
 An exception was thrown by the type initializer for 
      System.Windows.Forms.ThemeWin32Classic 
      ---> System.TypeInitializationException: 
 An exception was thrown by the type initializer for 
       System.Drawing.KnownColors 
        ---> System.TypeInitializationException: 
 An exception was thrown by the type initializer for 
        System.Drawing.GDIPlus 
        ---> System.DllNotFoundException: /tmp/install/lib/libgdiplus.so
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup                 (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unk
nown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:
0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x0
0000] in <filename unknown>:0
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000]
 in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
  at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unkn
own>:0
  at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unkno
wn>:0  
  at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0
  at HelloWorld..ctor () [0x00000] in <filename unknown>:0
  at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
  at HelloWorld.Main () [0x00000] in <filename unknown>:0
Run Code Online (Sandbox Code Playgroud)

小智 5

我遇到过这个问题.

我认为这是单声道的错误.

如果你安装了单声道 C:\Program Files (x86)\Mono-3.2.3\etc\mono

找到该文件 C:\Program Files (x86)\Mono-3.2.3\etc\mono\config

改变第29-30行:

<dllmap dll="gdiplus" target="/tmp/install/lib/libgdiplus.so" />
<dllmap dll="gdiplus.dll" target="/tmp/install/lib/libgdiplus.so" />
Run Code Online (Sandbox Code Playgroud)

至:

<dllmap dll="gdiplus" target="/tmp/install/lib/libgdiplus.so" os="!windows" />
<dllmap dll="gdiplus.dll" target="/tmp/install/lib/libgdiplus.so" os="!windows" />
Run Code Online (Sandbox Code Playgroud)

这个问题将得到解决.