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.
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: http://erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/
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: http://jrwren.wrenfam.com/blog/2008/11/01/gtk-in-visual-studio-2008-on-vista-x64/
I also added a reference to gtk-dotnet in addition to the ones from that guide.
This is my application's complete 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();
}
}
}
When I try to run this with any configuration, I get the following exception:
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:
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: glibsharpglue-2
glibsharpglue-2.dll
glibsharpglue-2.o
glibsharpglue-2.o.dll
! 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.
Any advice for my crazy problem? I feel like I'm missing something big here. >_<
GTK means "Good To Know." The abbreviation GTK is used with the meaning "Good To Know" to acknowledge the receipt of information that is useful or helpful. GTK can be used even if the information received is not something that you really wanted to hear.
GTK is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK is suitable for projects ranging from small one-off tools to complete application suites. . This package contains the example files and a demonstration program for GTK3.
GTK and C++ gtkmm is the official C++ interface for GTK. Highlights include typesafe callbacks, and a comprehensive set of widgets that are easily extensible via inheritance. You can create user interfaces in code using Gtk::Builder . There's extensive documentation, including API reference and a tutorial.
GTK is written using the C programming language, but its also available to various programming languages through language bindings, which allow writing GTK applications in the style of those languages. Language bindings are relatively easy to create because GTK is designed with them in mind.
I figured it out! Mono for Windows was completely unnecessary. GTK# for .NET is what I needed. For anyone in the future wanting to set up their Windows environment for cross platform GTK# development, here are the steps I followed:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With