在使用 Xamarin 开发 Linux 应用的时候,刚开始如果没有弄好 libglib-2.0-0.dll 的依赖库,那么将会在运行的时候,在 Gtk.Application.Init() 这句代码提示找不到这个库

解决方法是先到官网​ 下载 ​​GTK#​​ 安装包或 mono x86 的应用

安装到默认路径,也就是在 ​​C:\Program Files (x86)\GtkSharp\2.12\bin​​ 路径,默认安装的时候会加入到环境变量

接下来到 ​​C:\Program Files (x86)\GtkSharp\2.12\bin​​​ 复制 libglib-2.0-0.dll 文件到 xamarin 的输出文件夹,如 ​​D:\lindexi\t\Xamarin\Cla\bin\x86\Debug\net47​​ 文件夹里面,此时尝试运行,应该就不会存在这个提示

注意现在 GTK# 仅支持 x86 应用

DllNotFoundException: Unable to load DLL 'libgtk-win32-2.0-0.dll · Issue #937 · mono/xwt

Unable to load DLL 'libgtk-win32-2.0-0.dll' — Xamarin Community Forums

Gnome - Tomboy - Unable to load DLL 'libgtk-win 32-2.0-0.dll'

Index of /sources/gtk-sharp212

Xamarin.Forms/Xamarin.Forms.Platform.GTK at master · xamarin/Xamarin.Forms

jsuarezruiz/xamarin-forms-gtk-weather-sample: Xamarin.Forms GTK Backend Weather Sample

windows - Xamarin Studio, GTK 2.0 C# application, runtime error, can't load libglib-2.0-0.dll - Stack Overflow


我搭建了自己的博客 https://blog.lindexi.com/ 欢迎大家访问,里面有很多新的博客。

如果在博客看到有任何不懂的,欢迎交流,我搭建了 dotnet 职业技术学院 欢迎大家加入


本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。欢迎转载、使用、重新发布,但务必保留文章署名林德熙,不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请与我联系