我试图做的在C#我的第一个步骤,并希望建立一个空的GTK窗口,我的第一个任务。 通过macports
我安装了以下软件包:
- mono@2.10.9
- gtk-sharp@1.0.10
- gtk-sharp2@2.12.10
我也用的MonoDevelop从单主页。
我加入gtk-sharp.dll
(从/opt/local/lib/mono/gtk-sharp-2.0
)我引用。 我的代码如下所示:
using System;
using Gtk;
namespace lolbr_client
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine("Loading..");
Window window = new Window("test");
}
}
}
当我编译和运行代码片段,似乎在寻找和包括GTK库,它打印“中..”到控制台,但之后的行Console.WriteLine()
会导致此错误:
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
尽管特定的.dll文件并不在我的文件系统存在,快速locate gtksharpglue-2
显示了以下文件:
/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgtksharpglue-2.so
/opt/local/lib/libgtksharpglue-2.a
/opt/local/lib/libgtksharpglue-2.la
/opt/local/lib/libgtksharpglue-2.so
难道这些文件帮助我吗? 什么是下一阶段从这里调试/解决这一问题? 我已经搜索谷歌,但无论是我太新的这个主题来识别有用的信息,或有用的信息就是不存在。 有人能帮我吗? 提前致谢!
如何运行GTK夏普MONO应用程序(编译例如与Xamarin工作室)解决方案是做以下:
编译你的单/ GTK锋利的应用程序作为发布
创建shell脚本文件(bash)的这样的(名字也无妨,你愿意的话)
[sharp]!/bin/sh export DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib:$DYLD_FALLBACK_LIBRARY_PATH:/usr/lib" exec /Library/Frameworks/Mono.framework/Versions/Current/bin/mono ./AsketicExcel.exe
_3。 然后,你可以运行该形式的终端,或者您可以使用此包装工具http://sveinbjorn.org/platypus创造正常的OSX应用:)(包括在包中发布目录中的所有文件)
然后,为了运行其他Mac这个程序,你需要安装GTK#和单声道运行http://www.go-mono.com/mono-downloads/download.html
最后,它会是什么样子:
我发现这个问题,我dllmap
是不完整的。
我添加以下行/Library/Frameworks/Mono.framework/Versions/2.10.9/etc/mono/config
:
<dllmap os="osx" dll="libgtk-win32-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgtk-quartz-2.0.0.dylib" />
<dllmap os="osx" dll="glibsharpglue-2" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libglibsharpglue-2.so" />
<dllmap os="osx" dll="libgthread-2.0-0" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgthread-2.0.0.dylib" />
<dllmap os="osx" dll="libgthread-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgthread-2.0.0.dylib" />
<dllmap os="osx" dll="libglib-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libglib-2.0.0.dylib" />
<dllmap os="osx" dll="libgobject-2.0-0.dll" target="/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/libgobject-2.0.0.dylib" />
遇到了这个问题藏汉尽管Fabian的答案是正确的轨道上,这是不适合我的解决方案。 按照此错误与Xamarin日提交的 ,下面的项添加到dllmap
被要求要被添加到/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/config
(删除几个重复的)。
<dllmap os="osx" dll="glibsharpglue-2" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglibsharpglue-2.so" />
<dllmap os="osx" dll="gthread-2.0.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgthread-2.0.0.dylib" />
<dllmap os="osx" dll="gthread-2.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgthread-2.0.dylib" />
<dllmap os="osx" dll="glib-2.0.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.0.dylib" />
<dllmap os="osx" dll="glib-2.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglib-2.0.dylib" />
<dllmap os="osx" dll="glibsharpglue-2" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libglibsharpglue-2.so" />
<dllmap os="osx" dll="gtksharpglue-2" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgtksharpglue-2.so" />
<dllmap os="osx" dll="gobject-2.0.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.0.dylib" />
<dllmap os="osx" dll="gobject-2.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgobject-2.0.dylib" />
<dllmap os="osx" dll="gtk-quartz-2.0.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgtk-quartz-2.0.0.dylib" />
<dllmap os="osx" dll="gtk-quartz-2.0" target="/Library/Frameworks/Mono.framework/Versions/Current/lib/libgtk-quartz-2.0.dylib" />