Yes, I am crazy. Why would any programmer want this combination? I think it is a combination of wanting to work with the best tools, in this case Visual Studio 2008 and CodeRush and wanting to target Win32, OSX, and Linux all at once. The very nice part is that thanks to the hard work of other people, you don’t even have to run in Mono on Win32.
-
Install the GTK# SDK
You can get it from here: http://medsphere.org/projects/gtksharp/releases/2.10.4/gtksharp-sdk-2.10.4.msi
The project page is here:
http://medsphere.org/projects/gtksharp/
Thanks to the good folks at medsphere for maintaining this windows installer. Presumably they use this in their applications. - Create a new Windows Forms Project in Visual Studio.
Its fine to keep 3.5 framework selected. Mono supports the core parts of 3.5. - Remove the references to System.Windows.Forms.dll
- Add reference to atk-sharp, glib-sharp and gtk-sharp in the following paths:
C:\Program Files (x86)\Medsphere\Gtk# Runtime\lib\gtk-sharp-2.0\atk\atk-sharp.dll
C:\Program Files (x86)\Medsphere\Gtk# Runtime\lib\gtk-sharp-2.0\glib\glib-sharp.dll
C:\Program Files (x86)\Medsphere\Gtk# Runtime\lib\gtk-sharp-2.0\gtk\gtk-sharp.dll - Change your Platform target to x86 from AnyCPU in the project properties.
- Write some test code
- Run the application
[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(); }
Enjoy your 3rd option for a pure .NET programming GUI Toolkit on Win32. Winforms and WPF are great, but GTK# does fill a certain niche.
Don’t throw a shoe at me…but.. what do you gain by doing this? When ever I read posts like this – it makes me wonder – “Am I missing a better way of doing stuff – is this something cool that could my life easier?”
This is acctually great ,,, i have been searching for this kind of solution for a long time. The only thing that i can not find is something like build in linq using gtk ,, this would be the ultimate solution. thanks for this post dude
hi,
you have a comment on Scotts article onlMerge.
http://www.hanselman.com/blog/MixingLanguagesInASingleAssemblyInVisualStudioSeamlesslyWithILMergeAndMSBuild.aspx
i have tried to build two projects in visual studio as you defined but cannot get successful.
.netmodule produced for the second project is referenced as an external file but not linked, when its deleted the .exe file does not work.
am i missing something or its not possible to achieve within visual studio but by writing a make file?
thanks in advance
sorry for the inconvenience to ask here.
@David Pierce
I think you are correct, you cannot do it with Visual Studio. You may be able to do it with some custom msbuild rules, but my guess is that the Visual Studio experience will be very different than using project references. This is a major gripe of mine with the way Visual Studio utilizes msbuild.
Try a makefile or custom msbuild targets.
@dave pease
I won’t throw a shoe at you. I am an old linux guy, but I do like Visual Studio, so I want to write apps which target both Linux AND Windows and GTK# seems to be the best way to do that. If you don’t care about linux, then you can safely ignore this. You aren’t missing anything.
@Konstantin
What specifically do you mean “build in linq using gtk” You can use GTK# and all of the features of Linq in both Windows .NET and in Linux.
thanks jay.
Great post Jay!
The bad point is that you loose the Monodevelop’s Stetic designer which is the best designer to me. But is good to know that the posibility is there.
I am still working on DesktopRails to offer Gtk#/Windows.Forms/WPF portability.
Cheers mate
Does visual form designer works with gtk#?
Hi Jay,
what I i ment in my post was the ability to use full data binding using linq to mysql not MSsql altogether with GTK# without mono . I am not quite sure if you can do that yet!
I’m not familiar with linq to mysql, but it should work fine with nhibernate based objects or dblinq objects.
honestly, I’m not familiar enough with GTK# full data binding to comment on the details. I’ll look into it.
@lxx
No, the visual form designer is for windows forms.
It turns out that even in winforms, the form designer becomes far less useful once you want to do certain things. I stopped using the forms designer because it is too slow, and I can get more done without it.
nice blog BTW, I wish I read Russian.
I ended up doing this and it works quite well. I also reference glade-sharp and use the glade-3 UI editor.
Thanks!
thank you for sharing
[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();
}