我用C#学习Xamarin Studio一段时间了。我感到困惑,因为我无法通过命令'mono test.ext'在Debug目录中运行exe文件。这是以下错误消息:
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 MainWindow..ctor () [0x00000] in <filename unknown>:0
at BuildBoxTool.MainClass.Main (System.String[] args) [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 MainWindow..ctor () [0x00000] in <filename unknown>:0
at BuildBoxTool.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
我该怎么做才能解决它?感谢〜
答案 0 :(得分:0)
System.TypeInitializationException:抛出异常 Gtk.Container的类型初始值设定项---&gt; System.DllNotFoundException: gtksharpglue-2
默认情况下,Mono lib目录不会添加到任何全局dyld路径,有关详细信息,请查看dyld的手册页:
man dyld
~~~
DYLD_FALLBACK_LIBRARY_PATH
This is a colon separated list of directories that contain
libraries. It is used as the default location for libraries not
found in their install path. By default, it is set to
$(HOME)/lib:/usr/local/lib:/lib:/usr/lib.
~~~
所以要运行基于GTK#的test.exe&#39; :
export DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib:/usr/local/lib:/usr/lib"
mono test.exe