gpt4 book ai didi

c# - OSx 单声道 gtk Hello World 。 Gtk.Container 抛出异常

转载 作者:行者123 更新时间:2023-11-30 12:59:05 25 4
gpt4 key购买 nike

新安装后在 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

知道是什么原因造成的吗?

最佳答案

Jonathan Pryor 在 Xamarin forum 中很好地回答了这个问题.他的回答中的这些部分帮助了我:

You're not exporting $DYLD_LIBRARY_PATH or $DYLD_FALLBACK_LIBRARY_PATH so that it can be found.

...

The problem is that libgtk-quartz-2.0.0.dylib can't be found, because it's installed to /Library/Frameworks/Mono.framework/Libraries, not /usr/lib (or anything global).

首先在您的 shell 中运行以下命令,然后 mono hello.exe 应该可以运行:

export DYLD_FALLBACK_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib:/lib:/usr/lib

关于c# - OSx 单声道 gtk Hello World 。 Gtk.Container 抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27071038/

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