【发布时间】:2019-03-08 02:46:26
【问题描述】:
好吧,我完全不知所措。在过去的两个小时里,我一直在搞乱 Gtk# 和 Mono,但还没有到任何地方。
我已经使用链接available on Mono's website 安装了 Mono 和 GtkSharp。我还使用 MSYS2 从他们的网站安装了 Gtk。
我的应用程序的完整代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Gtk;
namespace InstallCheck {
public class GtkSharpTest {
public static void Main() {
Application.Init();
Window window = new Window("Hello Mono World");
window.Show();
Application.Run();
}
}
}
在 Visual Studio 中,我添加了对 glib-sharp.dll 和 gtk-sharp.dll 的引用。它构建得很好,但是当我使用mono InstallCheck.exe 运行它时,我得到了这个错误:
Unhandled Exception:
System.DllNotFoundException: libglib-2.0-0.dll
at (wrapper managed-to-native) GLib.Marshaller.g_utf16_to_utf8(char*,intptr,intptr,intptr,intptr&)
at GLib.Marshaller.StringToPtrGStrdup (System.String str) [0x00034] in <d973ca9f8b494b789fba7fe0ad040b14>:0
at GLib.Global.set_ProgramName (System.String value) [0x00001] in <d973ca9f8b494b789fba7fe0ad040b14>:0
at Gtk.Application.SetPrgname () [0x0000d] in <35293b6aa2744433b0e2f41f34e699d5>:0
at Gtk.Application.Init () [0x00001] in <35293b6aa2744433b0e2f41f34e699d5>:0
at InstallCheck.GtkSharpTest.Run () [0x00001] in <f385106059954ecb8802348d7a6abfe1>:0
at InstallCheck.GtkSharpTest.Main (System.String[] args) [0x00027] in <f385106059954ecb8802348d7a6abfe1>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libglib-2.0-0.dll
at (wrapper managed-to-native) GLib.Marshaller.g_utf16_to_utf8(char*,intptr,intptr,intptr,intptr&)
at GLib.Marshaller.StringToPtrGStrdup (System.String str) [0x00034] in <d973ca9f8b494b789fba7fe0ad040b14>:0
at GLib.Global.set_ProgramName (System.String value) [0x00001] in <d973ca9f8b494b789fba7fe0ad040b14>:0
at Gtk.Application.SetPrgname () [0x0000d] in <35293b6aa2744433b0e2f41f34e699d5>:0
at Gtk.Application.Init () [0x00001] in <35293b6aa2744433b0e2f41f34e699d5>:0
at InstallCheck.GtkSharpTest.Run () [0x00001] in <f385106059954ecb8802348d7a6abfe1>:0
at InstallCheck.GtkSharpTest.Main (System.String[] args) [0x00027] in <f385106059954ecb8802348d7a6abfe1>:0
我不知道这意味着什么。我已经用 Google 和 Bing 搜索过它,并且出现了问题,但他们提供的解决方案不起作用。是的,Mono 在我的路径中,是的,GtkSharp 也在我的路径中。我究竟做错了什么?这是 GTK 错误、Mono 错误还是 VS2017 错误?我如何解决它?提前致谢。
编辑:我现在尝试按照this issue 的建议降级 Gtk,但这仍然没有奏效。
【问题讨论】:
-
我看过这个问题。我已经重新启动,并寻找 .NET 运行时的东西。我唯一还没做的就是降级 Gtk。
-
你真的有原生的
libglib-2.0-0.dll吗? -
是的,它位于我的路径中引用的“bin”下的GSharp安装文件夹中
-
您还需要引用项目中的其他 dll,例如 atk-sharp 和 gdk-sharp。你不需要在你的机器上安装 Gtk,只要你已经安装了 Gtk#。我会尝试安装 monodevelop,看看它是否可以从那里工作。
-
我不想这么说,但如果有任何方法可以让它在 Visual Studio 上运行,我会很高兴。它比任何东西都更符合个人喜好......但另一方面,我试图将所有 dll 包含在 lib 文件夹中,但这也不起作用。抱歉,我应该明确指出。
标签: visual-studio visual-studio-2017 mono gtk#