title: GTK# in Visual Studio 2010
body: <p>I've been trying all day to get GTK# working in Visual Studio 2010 on Windows Server 2008 R2 x64 so that I can start writing nice cross-platform GUI applications, but I'm somewhat new to C# and I'm having a world of trouble.</p>
  
  <p>I installed the latest Mono for Windows which includes GTK#. I also installed a Mono 2.10.8 profile to be the target framework of my project loosely following the guide from here: <a href="http://erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/" rel="noreferrer">http://erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/</a></p>
  
  <p>I created a new Windows Forms application and removed references to the windows forms stuff and adding references for GTK# stuff, loosely following the guide from here: <a href="http://jrwren.wrenfam.com/blog/2008/11/01/gtk-in-visual-studio-2008-on-vista-x64/" rel="noreferrer">http://jrwren.wrenfam.com/blog/2008/11/01/gtk-in-visual-studio-2008-on-vista-x64/</a></p>
  
  <p>I also added a reference to gtk-dotnet in addition to the ones from that guide.</p>
  
  <p>This is my application's complete code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using System;
  using System.Runtime.InteropServices;
  using System.Collections.Generic;
  using System.Linq;
  using Gtk;
  
  namespace GridToGo
  {
      static class Program
      {
          [STAThread]
          static void Main()
          {
              Application.Init();
              Window myWin = new Window("My first GTK# Application! ");
              myWin.Resize(200, 200);
              myWin.Destroyed += new EventHandler(myWin_Destroyed);
              Label myLabel = new Label();
              myLabel.Text = "Hello World!!!!";
              myWin.Add(myLabel);
              myWin.ShowAll();
              Application.Run();
          }
  
          static void myWin_Destroyed(object sender, EventArgs e)
          {
              Application.Quit();
          }
      }
  }
  </code></pre>
  
  <p>When I try to run this with any configuration, I get the following exception:</p>
  
  <pre><code>System.TypeInitializationException was unhandled
    Message=The type initializer for 'Gtk.Application' threw an exception.
    Source=gtk-sharp
    TypeName=Gtk.Application
    StackTrace:
         at Gtk.Application.Init()
         at GridToGo.Program.Main() in F:\visual-studio\GridToGo\GridToGo\Program.cs:line 13
         at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
         at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
         at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
         at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.ThreadHelper.ThreadStart()
    InnerException: System.DllNotFoundException
         Message=Unable to load DLL 'glibsharpglue-2': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
         Source=glib-sharp
         TypeName=""
         StackTrace:
              at GLib.Thread.glibsharp_g_thread_supported()
              at GLib.Thread.get_Supported()
              at Gtk.Application..cctor()
         InnerException: 
  </code></pre>
  
  <p>I can't figure out how to get it to find that dll! I even tried copying 4 copies of the DLL into pretty much every folder in the solution with the following names: <code>glibsharpglue-2</code> <code>glibsharpglue-2.dll</code> <code>glibsharpglue-2.o</code> <code>glibsharpglue-2.o.dll</code>! I also even tried installing the GTK all-in-one package from the GTK site and adding its bin folder to my system path, and then copying the same 4 dlls into that folder, all with no luck.</p>
  
  <p>Any advice for my crazy problem? I feel like I'm missing something big here. >_&lt;</p>