Advertisment

Linux for Developer: .Net on Linux

author-image
PCQ Bureau
New Update

Microsoft’s .NET platform has become quite popular even though it was released just a couple of years back. The platform has not just given programmers a choice of platform (in terms of Web, Desktop and Device) but also a choice of language (there are more than 40 .NET languages. MS itself provides five languages out of the box, viz. VB, C++, C#, Jscript and J#). Now, with Mono, the platform also includes the choice of OS. 

Advertisment

Mono is an offering from Ximian, the guys who brought you GNOME and Evolution. This is an implementation of the .NET framework as well as the compiler and tools to allow you to create .NET applications for Linux as well as Windows. The compiler included in Mono, however, only compiles source code written in C#, but not in any of the other languages available. However, C# is an easy enough language to learn, especially for those who have prior experience with C++ or Java.

You can install and use Mono by selecting the Developer Workstation install type or the ‘Windows’ option in the Package selection screen. If you have already installed PCQLinux 2004, Mono is available in CD 2. Simply mount the CD and install Mono using the command: rpm

—ivh /mnt/cdrom/PCQLinux/ RPMS/mono-0.28-1.ximian.i386.rpm.

Once installed, you can start creating cross-platform applications very easily. For instance, open your favorite text editor on PCQLinux and enter the following code in it.

Advertisment

using System;



class Hello


{


static void Main ()


{


Console.WriteLine (“Hello World”);


}


}





Save this file as Hello.cs in your home folder. The next thing you need to do is compile this .NET code on Linux. Mono gives a program called mcs for this task. Simply run the command: mcs Hello.cs on the terminal. If there are no syntax errors, you will end up with a file called

Hello.exe. 

To run this file on the Linux platform, at the command prompt, issue the command: mono Hello.exe. This command supplies the .NET framework dependencies to the exe and executes it in the .NET environment. 

Advertisment

Now comes the fun part! Copy this file over to any Windows machine that has the .NET framework already installed. To run this file (that was compiled and run successfully on Linux), simply double click on it. It will run under Windows as well!

For graphical Mono applications, an additional program is also required, which is not present on the CDs. You can download GTK# from http://gtk-sharp.sourceforge.net/. Use this to create graphical .NET applications for both Windows and Linux.

Vinod Unny

Advertisment