如何使用Visual Studio 2017构建Gtk#/ Mono应用程序

问题描述 投票:0回答:1

好吧,我完全失去了。过去两个小时我一直在搞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

我不知道这是什么意思。我已经谷歌和Bing了,事情出现了,但他们提供的解决方案没有用。是的,Mono在我的路径中,是的,GtkSharp也在我的路径中。我究竟做错了什么?这是GTK错误,单声道错误还是VS2017错误?我如何解决它?提前致谢。

编辑:我现在尝试按照this issue的建议降低Gtk,但这仍然没有用。

visual-studio visual-studio-2017 mono gtk#
1个回答
0
投票

你可以使用nuget包GtkSharp.Win32在Visual Studio 2017中创建一个Gtk应用程序.https://github.com/jhojen26/GtkSharpTest

© www.soinside.com 2019 - 2024. All rights reserved.