在新安裝後試用Mono中的hello world示例。試過GTK例子如[指示:OSx單聲道gtk問候世界。 Gtk.Container引發了一個例外
mcs hello.cs -pkg:gtk-sharp-2.0
mono hello.exe
,我得到這個:
> 2014-11-21 21:45:29.629 mono[45107:1731007] *** WARNING: Method
> userSpaceScaleFactor in class NSView is deprecated on 10.7 and later.
> It should not be used in new applications. Use convertRectToBacking:
> instead.
>
> Unhandled Exception: System.TypeInitializationException: An exception
> was thrown by the type initializer for Gtk.Container --->
> System.DllNotFoundException: gtksharpglue-2 at (wrapper
> managed-to-native)
> Gtk.Container:gtksharp_gtk_container_get_focus_child_offset() at
> Gtk.Container..cctor() [0x00000] in <filename unknown>:0 --- End
> of inner exception stack trace --- at Gtk.Bin..ctor (IntPtr raw)
> [0x00000] in <filename unknown>:0 at Gtk.Window..ctor (WindowType
> type) [0x00000] in <filename unknown>:0 at Gtk.Window..ctor
> (System.String title) [0x00000] in <filename unknown>:0 at
> Hello.Main() [0x00000] in <filename unknown>:0 [ERROR] FATAL
> UNHANDLED EXCEPTION: System.TypeInitializationException: An exception
> was thrown by the type initializer for Gtk.Container --->
> System.DllNotFoundException: gtksharpglue-2 at (wrapper
> managed-to-native)
> Gtk.Container:gtksharp_gtk_container_get_focus_child_offset() at
> Gtk.Container..cctor() [0x00000] in <filename unknown>:0 --- End
> of inner exception stack trace --- at Gtk.Bin..ctor (IntPtr raw)
> [0x00000] in <filename unknown>:0
> at Gtk.Window..ctor (WindowType type) [0x00000] in <filename
> unknown>:0
> at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0
> at Hello.Main() [0x00000] in <filename unknown>:0
任何想法是什麼引起的呢?
請注意,喬納森建議創建一個腳本(見下文)。我的經驗是OS X在涉及DYLD變量的環境變化方面表現不佳。 – 2015-09-15 20:46:58