September 15, 2004

Mono and Gtk# development in Windows

A lot of folks have been asking recently how and where to use what installer. For a lot of us who use IRC, it may be a good thing to look over my notes below and -- correct me if necessary -- later spread the word about this. I hope this helps.

If you want to use Visual Studio .NET 2003 to build Gtk# applications that will run without having Mono installed in your system. Use:

http://forge.novell.com/modules/xfmod/project/?gtks-inst4win

If you don't have Visual Studio .NET 2003 but want to code using your favorite editor and perhaps nmake (a Make tool specifically design for Windows). You need to *FIRST* install the Microsoft .NET Framework 1.1 SDK. This is available here (watch out for URL wrapping):

http://www.microsoft.com/downloads/details.aspx?familyid=9b3a2ca6-3647-4070-9f41-a333c6b9181d&displaylang=en

Then you install the Gtk# Win32 installer for the MS .NET Framework SDK 1.1 available here:

http://forge.novell.com/modules/xfmod/project/?gtks-inst4win

Using the software components described above, you could use csc.exe -- that is the C# compiler supplied by Microsoft -- to build your executable and/or library module assemblies. If it is an executable, you could run it from the command line by just simply specifying the fully qualified path to the resulting exe file.

Since Mono is just awesome, you could take that same executable archive it into a zip file, copy it to a Linux or Mac OS X computer configured to run Mono/Gtk# and run it there using a command line similar to this:

mono ~/bin/MyGuiApp.exe

The Mono runtime will use the Just In Time (JIT) compilation technology and turn it int native code which will give it the best performance during execution. There are times when you are targeting a new type of hardware (like a new CPU) that may not have JIT available yet but may already be supported by mint. In such case you can use a command line like this:

mint ~/bin/MyGuiApp.exe

The Mono interpreter (mint.exe) will be able to interpret the intermediate language (IL) that is enclosed in your file and run it as appropriate in accordance with the local machine's runtime knowledge of the underlying operating system and hardware.


If you just want to be able to run applications you have already compiled in Linux while you are on a Windows machine, you could try the Mono Combined installer. You should be able to build/run your Gtk# application you compiled in Linux -- provided you don't have GNOME dependencies -- in Windows without any other piece of Microsoft supplied software. The latest Mono combined installer is available here:

http://forge.novell.com/modules/xfmod/project/?monowin32

Having the Microsoft .NET Framework and/or SDK installed in your computer prior to the Mono Combined installer or afterward should not matter. The Mono Combined installer does not interact with the Microsoft .NET Framework. It has its own Global Assembly Cache (GAC) and it is not placed on the system PATH during the installation -- This is by design.

A very common scenario has a developer who has developed an application using Mono. THE ACID TEST IS: IF YOU USED MCS.EXE TO COMPILE YOUR PROGRAM PLEASE LISTEN. That developer would then take his/her resulting binary output (e.g. MyApp.exe) and could run it on a Windows computer that had the Mono combined installer by going to the Start Menu of that computer and opening the Mono 1.0.1 Command Prompt. This will spawn a console session that is at that point configured correctly with a Mono runtime environment. Just as you would on a Linux shell (Bash or Tcsh) you could then run you application by type a command line similar to this:

C:\>mono d:\PacoBin\MyApp.exe

It turns out that I had written about this before. This may just abound and complement my previous entry.

Thank you Lluis and kangaroo.

Posted by martinf at September 15, 2004 07:23 AM
Comments

We've built some GUI apps using Microsoft Studio which have issues when run under Mono.
When loading image streams from resources in an assembly using the ResourceManager we've found the Mono CLR cannot perform the type conversions which are supported by the Microsoft CLR.

The microsoft tools output the following code:

this.largeImageList.ImageStream = (System.Windows.Forms.ImageListStreamer)(resources.GetObject("largeImageList.ImageStream")));

GetObject returns a System.String containing the base64 imagestream data.

The type conversion to an ImageListStreamer type generates an exception "Cannot cast from source type to destination type."

Any help you can give would be appreciated.

Thanks.

Posted by: Roger Twede at September 16, 2004 10:58 AM

Actually, the gtk# installer seems to check for Visul C#. It wouldn't install even though I had the 1.1 SDK installed.

Posted by: Ben at September 18, 2004 02:56 PM

The installer at:

http://forge.novell.com/modules/xfmod/project/?monowin32

seems corrupted?

I downloaded several times by both ftp and http and even onto different machines and the md5sum never matched the one supplied.

Is this a known problem?

Posted by: MartinG at September 20, 2004 09:22 AM