Use mono for. Net open source programming |
Author: Tony Patton AM |
Mono is an open-source Platform Based on. NET Framework. This article describes how the platform provides flexible development mechanisms in windows, OS X, and a variety of Unix/Linux systems.
What is mono?
The birth of Mono is based on the fact that the C # language and CLI (command language infrastructure, the general language architecture) have been accepted as the standard for ECMA. The mono library includes the. NET compatible libraries (including ADO. net, system. Windows. forms, and ASP. NET) and third-party class libraries specified by mono. You can also embed mono runtime into your application, making it easier to package and release your application. In addition, Mono provides an IDE, a debugger, and a document browser.
How to install mono
Mono can be obtained free of charge (http://www.mono-project.com/Downloads) from the project's web site, you can choose to download Linux (general-purpose installation version, support Suse and Red Hat) different versions under Windows and OS X. You can download all the source code and compile it (if your platform does not support the above three versions, this will be the only way), or directly download the appropriate installation package. This document describes how to download the installation package.
Once the required installation package is downloaded based on your platform, the installation process varies with the operating system. At the time of writing this article, I installed mono on two computers running Windows XP and SuSE Linux 9.2. In Windows, the installation process is very simple. You only need to download the installation package and run it on the system. The other operating system is somewhat difficult to handle. In Linux, the installation includes multiple independent files, which are related to different functions of the mono platform. Here are some mono software packages for SuSE:
* Mono-devel- 1.0.6-1. ximian.9.1.i586. rpm-mono core package and C # Compiler
* Mono-core- 1.0.6-1. ximian.9.1.i586. rpm-mono core Runtime
* Mono-data- 1.0.6-1. ximian.9.1.i586. rpm-Database Core
Every file in the list is a red hat Package Manager file. These files must be installed using the RPM command line tool in Linux. For example, you can run the following command to install Mono:
Rpm-I mono-core- 1.0.6-1. ximian.9.1.i586. rpm
After the installation is complete, you need to immediately add the relevant directories to the system directory, so that you do not need to specify the complete path to use the relevant commands. In Windows, you must use the control panel. in Linux, the path command is used. Note: If you encounter any problems during the installation process, I suggest you access got mono? Web site (http://www.gotmono.com /). It provides a good reference for troubleshooting.
Mono tool set
After installing mono, you may use various of its tools. The following are part of these tools:
* Mono-mono interpreter. Applications can be executed without JIT. This tool allows you to run applications from the command line. There are no related tools in Microsoft. NET Framework.
* MCS-C # compiler. This compiler accepts the same command line options as Microsoft C # compiler.
* Monodies-this tool allows applications to be converted to Il (intermediate language is the intermediate language ). The specific function is inferior to Microsoft ildasm.exe.
For a complete list of tools, see the mono documentation. This document describes the options of each command.
Create a mono Application
Now let's create a simple application to see how to use these tools. The following code outputs a simple message to the console:
Using system;
Namespacebuilder. Samples {
Public class monodemo {
Public static void
Main (string [] ARGs)
{Console. writeline ("check out
Builderau.com. Au ");
}}}
We save the above Code as monodemo. CS, and then use the C # compiler of Mono:
Mcsmonodemo. CS
The compilation result is the monodemo.exe file. The. exe extension of this file is very common in windows, but not in Linux.
Therefore, we use the command line interpreter to run our example program: Mono monodemo.exe. The key to this example is that we can run compiled files on any platform such as Windows, Linux, Mac OS X that can run mono or the windows. NET Framework. This is because the mono compiler compiles the code into a well-known il intermediate form. Microsoft's C # compiler does the same job, But mono does not have a complete. Net class library installed. It installs an additional specified mono library. Therefore, not all mono-developed applications can run under Microsoft. NET Framework, and vice versa.
Therefore, when determining the target platform and future compatibility requirements, you must take this into consideration. You should also visit mono sites frequently. Because the site often provides some new functions (such as class libraries), you can keep your projects updated at any time. This is also true for Microsoft products.