在新安装后尝试使用Mono中的hello world示例。按[http://www.mono-project.com/docs/getting-started/mono-basics/][1]:
的指示尝试了GTK示例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
知道是什么导致了它吗?
答案 0 :(得分:0)
Jonathan Pryor在Xamarin forum中非常好地回答了这个问题。他回答的这些内容帮助了我:
您没有导出$ DYLD_LIBRARY_PATH或$ DYLD_FALLBACK_LIBRARY_PATH以便找到它。
...
问题是无法找到libgtk-quartz-2.0.0.dylib,因为它已安装到/Library/Frameworks/Mono.framework/Libraries,而不是/ usr / lib(或任何全局)。
首先在shell中运行以下内容,然后mono hello.exe
应该可以运行:
export DYLD_FALLBACK_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib:/lib:/usr/lib
答案 1 :(得分:0)
第一条错误消息
GTK的用户可以忽略&#34;类NSView中的userSpaceScaleFactor在10.7及更高版本中被弃用&#34;
。但是,在Apple删除引用的调用之前,GTK开发人员社区必须更新其代码。
Apple Dev Community Notices re userSpaceScaleFactor
用于隔离第二个问题的脚本。不要忘记chmod + x它。
#!/bin/zsh
export DYLD_FALLBACK_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib:/lib:/usr/lib
mono $1.exe