0
votes

Alright, I'm at a complete loss. I've been messing with Gtk# and Mono for the past two hours and have yet to get anywhere.

I've installed Mono as well as GtkSharp using the links available on Mono's website. I have also installed Gtk itself from their website using MSYS2.

The full code of my application is below:

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();
        }
    }
}

In Visual Studio, I've added references to glib-sharp.dll and gtk-sharp.dll. It builds just fine, but when I go to run it using mono InstallCheck.exe, I get this error:

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

I have no idea what this means. I've Google'd and Bing'd it, and things came up, but the solutions they provided did not work. Yes, Mono is in my Path, and yes, GtkSharp is also in my Path. What am I doing wrong? Is this a GTK Error, a Mono Error, or a VS2017 error? How do I fix it? Thanks in advance.

Edit: I have now attempted to DOWNGRADE Gtk, as recommended by this issue, but that still did not work.

1
I've seen that question. I've rebooted, and looked for .NET Runtime stuff. The only thing I haven't done yet is downgrade Gtk.FireController1847
Do you actually have the native libglib-2.0-0.dll?SushiHangover
Yes, it's located in the GSharp installation folder under "bin", which is referenced in my PathFireController1847
You need also references to other dll's in your project, such as atk-sharp and gdk-sharp. You don't need to install Gtk in your machine, provided you've already installed Gtk#. I'd try installing monodevelop, and see if it works from there.Baltasarq
I hate to say this, but I'd love if there's any way to get it working on Visual Studio. It's more personal preference than anything... But on the other note, I have attempted to include ALL the dll's in the lib folder, and that did not work either. My apologies, I should have specified that.FireController1847

1 Answers

0
votes

you can use the nuget package GtkSharp.Win32 to create a Gtk application in Visual Studio 2017. https://github.com/jhojen26/GtkSharpTest