How to run mono on Linux

Source: Internet
Author: User

As we all know, C # Is A. Net Language launched by Microsoft and can only run on. NET platforms, such as win 9x, me, and N.
Operating systems such as t, 2000, XP, and Win CE. However, now there is a project called Mono, its goal
Is to put. NET andProgramming LanguageTo a non-Windows platform. Now, C # is the only one that has been ported to a non-Windows
The. NET language of the platform.

Write and run on any platform (operating system + Hardware System)ProgramThe three most fundamental requirements
Interpreter/Interpreter and runtime environment. Library provides common routines in the form of classes and methods (functions) to simplify
Write .. . NET Framework, including many class libraries. In addition, the program is converted into executable form and running execution
The compiler and runtime environment are essential for row files. The mono package contains a part of the. NET class library,
C # compiler and. Net runtime environment CLR (Common Language Runtime ).

Mono claims to support Linux, Solaris, Free BSD, and MS Windows; apart from Intel x86 series CPUs (486,
In addition to various Pentium and so on, it is said that it also supports the iSCSI, PowerPC and strongarm processors.

Next let's take a look at how to run mono on Linux.

Command Line Application

First download the software from the mono home page (http://www.go-mono.com/) and execute the following command to install all RPM:

Rpm-IVH *. rpm

After the installation is complete, all basic dynamic execution libraries, including system. Data. dll, system. dll, and system. Draw
Ing. dll, system. Web. dll, and system. xml. dll are all copied to/usr/lib. Next, in Linux
In this editor, enter the following content and save the file as hellomono. CS:

Class hellomono
{
Public static void main (string [] ARGs)
{System. Console. writeline ("Hello mono ");
}
}

Run the following command to compile the C # file:

MCS hellomono. CS

MCS is the C # command line compiler of Mono. Similar to the CSC compiler of the MS. Net SDK, MCS also has many command line options.
. The authorization command will generate the executable file hellomono.exe. Note that this execution file is not a Linux execution file,
It is a. Net execution file, or the executable file.CodeThe format is intermediate language (IL, intermed
Iate language ). To run this execution file, you must execute the following command:

Mono hellomono.exe

"Hello mono" is displayed on the Linux console ". For more information about MCS and mono, Run man MCS or man
Mono references its man document.

GUI applications

Mono does not support Windows Forms, but GTK # can be used to compile the GUI in C # programming. GTK # Is the C # branch of GTK + graphics library
Download the tool from http://gtk-sharp.sourceforge.net. After downloading, install RPM:

Rpm-uvh *. rpm -- nodeps
Open gtk-sharp-0.2.1.tar.gz:
Tar-zxvf gtk-sharp-0.2.1.tar.gz
Go to the subdirectory gtk-sharp-0.2.1 and execute:
./Configure -- prefix =/usr
Make
Make install

After completing this step, restart once. All dynamic code modules related to GTK # (gtk-sharp.dll,
Tk-sharp.dll, gdk-sharp.dll, glib-sharp.dll, and pango-sharp.dll will be copied to/u
Sr/lib directory. When compiling a C # program using GTK # To create a GUI, you must reference them using the-R parameter. GTK # download package
Contains several sample programs, such as helloworld. CS, menu. CS, and buttonapp. CS. Command for compiling these files
As follows:

MCS-r GTK-sharp-r glib-sharp helloworld. CS
MCS-r GTK-sharp-r glib-sharp-r system. Drawing menu. CS
MCS-r GTK-sharp-r glib-sharp-r system. Drawing buttonapp. CS

Next let's take a look at how to reference the previous. dll dynamic modules through the-r option. Run the startx command to start X Window,
Enter the terminal window, enter the directory where the sample program is located, and run the following commands to run each program:

Mono helloworld.exe
Mono menu.exe
Mono buttonapp.exe

The mono project is still under improvement and development, and all. Net classes have not been transplanted. However, for many people
It will be good news. For information about the migration progress of Mono C # class library, visit www.go-mono.com/class-sta.
Tus.html.

Consider a typical server/client. NET application: the end user only deals with the client, preferably
Many people also want to use a familiar Windows platform. However, for them
Windows or Linux is completely irrelevant. Therefore, the server can be constructed in Linux with mono, saving Configuration
Investment in dedicated backup Windows servers. Mono also facilitates application migration. If mono can develop smoothly, W
Indows developers will be able to develop applications for Linux or other non-Windows platforms. If so, soon after
There may be a free or cheap Linux development ide similar to Visual Studio. NET.

However, whether all these tasks can become a reality depends on whether mono can thrive or on Mono and WI.
The. NET Framework on the ndows platform is compatible or similar. Other factors are also critical, such as mono performance, Gui
.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.