title: How to build a Gtk#/Mono Application using Visual Studio 2017
body: <p>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.</p>
  
  <p>I've installed Mono as well as GtkSharp using the links <a href="https://www.mono-project.com/download/stable/" rel="nofollow noreferrer">available on Mono's website</a>. I have also installed Gtk itself from their website using MSYS2.</p>
  
  <p>The full code of my application is below:</p>
  
  <pre><code>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();
          }
      }
  }
  </code></pre>
  
  <p>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 <code>mono InstallCheck.exe</code>, I get this error:</p>
  
  <pre><code>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&amp;)
    at GLib.Marshaller.StringToPtrGStrdup (System.String str) [0x00034] in &lt;d973ca9f8b494b789fba7fe0ad040b14&gt;:0
    at GLib.Global.set_ProgramName (System.String value) [0x00001] in &lt;d973ca9f8b494b789fba7fe0ad040b14&gt;:0
    at Gtk.Application.SetPrgname () [0x0000d] in &lt;35293b6aa2744433b0e2f41f34e699d5&gt;:0
    at Gtk.Application.Init () [0x00001] in &lt;35293b6aa2744433b0e2f41f34e699d5&gt;:0
    at InstallCheck.GtkSharpTest.Run () [0x00001] in &lt;f385106059954ecb8802348d7a6abfe1&gt;:0
    at InstallCheck.GtkSharpTest.Main (System.String[] args) [0x00027] in &lt;f385106059954ecb8802348d7a6abfe1&gt;: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&amp;)
    at GLib.Marshaller.StringToPtrGStrdup (System.String str) [0x00034] in &lt;d973ca9f8b494b789fba7fe0ad040b14&gt;:0
    at GLib.Global.set_ProgramName (System.String value) [0x00001] in &lt;d973ca9f8b494b789fba7fe0ad040b14&gt;:0
    at Gtk.Application.SetPrgname () [0x0000d] in &lt;35293b6aa2744433b0e2f41f34e699d5&gt;:0
    at Gtk.Application.Init () [0x00001] in &lt;35293b6aa2744433b0e2f41f34e699d5&gt;:0
    at InstallCheck.GtkSharpTest.Run () [0x00001] in &lt;f385106059954ecb8802348d7a6abfe1&gt;:0
    at InstallCheck.GtkSharpTest.Main (System.String[] args) [0x00027] in &lt;f385106059954ecb8802348d7a6abfe1&gt;:0
  </code></pre>
  
  <p>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.</p>
  
  <p>Edit: I have now attempted to DOWNGRADE Gtk, as recommended by <a href="https://stackoverflow.com/questions/34279001/xamarin-studio-gtk-2-0-c-sharp-application-runtime-error-cant-load-libglib-2">this issue</a>, but that still did not work.</p>