Read Digital Edition


ADS BY GOOGLE
Top Three Links You Must Click On


Getting Started in Linux for the Experienced .NET Developer
Get your applications ready for the world's fastest-growing OS

The GTK# classes are used in the Linux world. They use the GIMP GTK+ libraries, which are most commonly found in the GNOME desktop environment, although they can also be loaded on systems using the KDE desktop. The GTK# classes provide a simplified way of producing .NET applications for the Linux environment, although they are obviously not compatible with the Windows environment. If you are writing applications specifically for the Linux platform, the GTK# classes are a great tool to use.

ASP.NET Support
So now we have covered both console and windows applications in .NET. You are probably wondering about the other .NET programming environment, ASP.NET.

The development environment for ASP.NET is normally the Windows IIS Web server; however this server is not portable to Linux. Instead, Mono provides two alternative solutions to this problem.

The first option is an ASP.NET plug-in module for the Apache Web server. The Apache Web server is the most popular Web server used on the Linux platform. The Mono mod_mono Apache module provides the necessary ASP.NET functions to an existing Linux Apache server. For high-volume server applications, this is the way to go.

The second option is a stand-alone ASP.NET server called XSP. The XSP project provides a complete Web server written in C# code. It's not ideal for larger applications, but it works fine for most small- and medium-sized situations. Since it is written in C# code, it's completely portable to the Windows platform. It can run on either Linux or Windows as an ASP.NET Web server.

Both mod_mono and XSP provide support for standard ASP.NET Web forms and Web services. Let's test out a Web service project to see how it works.

Listing 2, MathService.asmx, is a program I used in my C# Network Programming book to illustrate a basic Web service program. It creates a Web service that supplies four math methods - addition, subtraction, multiplication, and division.

Create the MathService.asmx program in a test directory on your Linux server. From the test directory, start XSP by typing xsp on the command line. The XSP server starts and tells you the listening address (it uses address 0.0.0.0 to indicate it is listening to all addresses on the server) and the port it uses (by default, port 8080). You can test the Web service by connecting to it with a browser, as shown in Figure 1.

Now it's time to create the Web service proxy. Just as in .NET, Mono provides the WSDL program to connect to a Web service, and create the .cs file with the proxy methods. The command line format is:

$ wsdl http://localhost:8080/MathService.asmx

This creates the MathService.cs file. After the file is generated, you can create a proxy library file for the Web service:

$ mcs /t:library MathService.cs

This creates the MathService.dll program. This Web proxy client program can be used on both Windows and Linux clients. Now let's create a client program to use the proxy.

Listing 3 shows the ServiceTest.cs program. It uses the MathService class to utilize the Web service methods. Compile the client program using the command line:

$ mcs /r:System.Web.Service.dll /r:MathService.dll ServiceTest.cs

You must include the System.Web.Service library as well as the specific Web service proxy library file. The resulting program is ServiceTest.exe. Running the program produces the expected results from the Web service server:

$ mono ServiceTest.exe 100 50
The answers are:
100 + 50 = 150
100 - 50 = 50
100 * 50 = 5000
100 / 50 = 2
$

What About an IDE?
Now that you have seen what Mono can do, you might be wondering if you are stuck using text editors and command-line programs to develop Mono applications. The answer is monodevelop.

Monodevelop is a graphical IDE environment for creating C# and GTK# applications. While it's not as advanced as Visual Studio, it does have many of those features with which you are already familiar. When starting a new project in Monodevelop, a wizard dialog displays that asks you to select the project type. When you select a project type and name, a rough code template is created for you, as shown in Figure 2.

Select the project type you're interested in, type in a name for your project, and away you go. As you type in your program, monodevelop tracks the variables, methods, and classes created. Figure 3 shows the SampleClass.cs program from Listing 1 as a console project.

Summary
Creating .NET applications on non-Windows platforms can be challenging, but with Mono all of the tools you need are readily available. The Mono mcs C# compiler generates .NET applications that can run on both Windows and Linux platforms. The mod_mono and XSP Web servers provide ASP.NET functions for Web forms and Web services. Finally, for a graphical development environment, the monodevelop IDE provides an easy way to create .NET programs on Linux.

About Richard K. Blum
Richard Blum currently works for a large US government organization as a network and systems administrator. He is the author of C# Network Programming (2002, Sybex) and Professional Assembly Language (2005, Wrox).

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

David,

I agree with you completely. WinForms is the key.

http://crossplatformdotnet.blogspot.com/2005/11/getting-started-in-linux...

Gtk# _is_ Windows compatible. Just take a look at the home page: http://gtk-sharp.sourceforge.net/. Mono is a lot closer to being cross platform than Microsoft's implementation.

Gtk+ also works on Windows, and that is how projects like gaim can be ported.

Linux and Microsoft: Getting Started in Linux for the Experienced .NET Developer. As an experienced .Net developer, I'm sure you are comfortable creating programs in your home environment - using Visual Studio on a Windows PC. What about using other platforms? In the .NET world, not many developers think much about cross-platform development. However, with the growing popularity of Unix, and specifically Linux, as a server platform, it might be time to consider a cross-platform .NET development environment.

Linux and Microsoft: Getting Started in Linux for the Experienced .NET Developer. As an experienced .Net developer, I'm sure you are comfortable creating programs in your home environment - using Visual Studio on a Windows PC. What about using other platforms? In the .NET world, not many developers think much about cross-platform development. However, with the growing popularity of Unix, and specifically Linux, as a server platform, it might be time to consider a cross-platform .NET development environment.


  Subscribe to our RSS feeds now and receive the next article instantly!
In It? Reprint It! Contact advertising(at)sys-con.com to order your reprints!
Subscribe to the World's Most Powerful Newsletters

ADS BY GOOGLE
InformationWeek stumbled on a Microsoft patent application dating back to 2006 deceptively titled “M...
Berlin-based ThinPrint AG, the printer virtualization house, thinks it’s got a cloud solution for th...
The second set of charges filed last week against Indian outsourcer Satyam Computer Services founder...
IBM has acquired Guardium, a seven-year-old subsidiary of Israel’s Log-On Software transplanted to M...
But on the web, access to services is implicit in the fact that the business is offering the service...
Gartner told Reuters that it overestimated how many PCs Acer shipped in the last seven quarters by a...
Oracle has offered to cordon off MySQL inside a combined Oracle-Sun to get the European Commission t...
Intel has put out its promised beta SDK for Windows (C and C++) and Moblin (C) developers working on...
Behaving like it’s got a future, Sun Monday put out what it calls a significant new version of Virtu...
Gartner is buying ~$40 million-a-year AMR Research Inc for close to $64 million in cash. AMD special...
Singed by user reaction to its plans to up the price of its support contracts, SAP Tuesday postponed...
Apparently Google Gears ain’t gonna stick around that long. Google Apps will eventually get their of...
Gartner thinks the server business has stopped sliding into the abyss. Third-quarter sales weren’t a...
Office Web Apps, Microsoft’s answer to Google Apps, are supposed to be out sometime in June along wi...
Oracle seems to have divided the open source ranks over the MySQL delay it’s having closing its acqu...
The Korean government is going to sink around $172 million into cloud computing next year under a st...
We hear – well, you know how people talk – that Oracle has been quietly meeting with the European Co...
In response to Opera’s complaints Microsoft has reportedly modified the proposed ballot screen that’...
CA is looking for talent in EMEA: associate account managers, directors of solution sales, senior so...
Microsoft has sold the Folio and NXT businesses it got when it bought Fast Search and Transfer, the ...