Microsoft's. NET Framework and Linux development and management are two of the most popular topics in buider Au and a wider industry.
Most of the time, these two themes often conflict, and few developers need to understand these two tools at the same time. However, many people do not realize that we can combine the two through the open-source mono program. This article describes how to install mono on Linux and run BASIC. NET applications.
First, you need to use apt-get to install the basic mono software package. In this case, it is best to install the other two software packages: monodevelop, a mono development environment similar to Visual Studio (although far less complex than Visual Studio) in some aspects, and monodoc that provides help and technical documentation.
Start a root terminal and enter:
% Apt-Get install mono monodevelop monodoc
The mono application is ready, but you 'd better add some additional parts you need.
% Apt-Get install mono-utils mono-xsp monodoc-HTTP
If you want to perform some development work from the terminal, mono-utils can provide you with some useful tools. Monodoc-HTTP provides the monodoc manual in the form of web services. It must be an independent mono-xsp Web server to run. Mono includes mono C # compiler MCS, but it can only be compiled. NET 1.1 code, if you want to use. NET 2.0 C # features (such as very helpful generics), then you need GMCs:
% Apt-Get install mono-GMCs
If you plan to write your code using monodevelop, you can install many software packages supported by SVN, Java, nunit, Boo, and monoquery:
% Apt-Get install monodevelop-versioncontrol monodevelop-Java monodevelop-nunit monodevelop-boo monodevelop-Query
Similarly, if you plan to use monodoc (strongly recommended), you can install the manual for the Toolbox you will use.
% Apt-Get install monodoc-nunit-manual monodoc-IPod-manual monodoc-gtk2.0-manual
Before writing the code, let's take a look at some of the tools we just installed. The monodoc Browser allows you to view the mono manuals you have installed, including useful references to C # language standards.
Or, if you want to, you can also read this document in a web browser. The monodoc-HTTP program starts an xsp server running locally, allowing you to establish a connection with any web browser.
If you want to, you can also start monodevelop IDE, although in our example, you do not need such powerful functions.
Now we try some code to check the entire mono package. Take the Standard C # Hello World Program as an example:
Using system;
Namespace Hello {
Class helloworld {
Public static void main (string [] ARGs ){
Console. writeline ("Hello world! ");
}
}
}
After editing with MCS, run the command mono. The result is as follows:
The above code runs normally, but this is a very simple example. It does not include. Net's most commonly used part: Windows Forms. Next, let's see if a simple Windows Forms Application can run. First, make sure that the relevant libraries are installed:
% Apt-Get install libmono-winforms1.0-cil libmono-winforms2.0-cil
The source code is as follows:
Using system;
Using system. Windows. forms;
Namespace helloclickworld {
Public class Hello: FORM {
Public static void main (string [] ARGs ){
Application. Run (New Hello ());
}
Public Hello ()
{
Button button = new button ();
Button. Text = "click ...";
Button. Click + = new eventhandler (button_click );
Controls. Add (button );
}
Private void button_click (Object sender, eventargs E)
{
MessageBox. Show ("Hello click World! ");
}
}
}
This compilation of the Assembly is more complex, because you need to tell C # That the compiler includes the Windows Forms Library:
% MCS-R: system. Windows. Forms hiclickworld. CS
% Mono hiclickworld.exe
Finally, you must ensure that ASP. NET works properly. Use index. aspx as the file name to save the following code:
<% @ Page Language = "C #" %>
<SCRIPT runat = "server">
Void button#click (Object sender, eventargs E)
{
Label1.text = "Hi click World! ";
}
</SCRIPT>
<HTML>
<Head>
<Title> Hello World </title>
</Head>
<Body>
<Form runat = "server">
<Asp: button id = "button1" onclick = "button#click" runat = "server" text = "button"/>
<Asp: Label id = "label1" runat = "server"/>
</Form>
</Body>
</Html>
Enable an xsp server in that directory.
In the last step, enter http: // localhost: 8080/in the web browser and check the newly created ASP. NET Website in Linux:
If all functions run normally, all Mono is installed. You can develop applications on Linux or windows and deploy them on any system.
Warning Mono is not a perfect alternative ,. some functions of the net framework cannot be run in Mono currently, especially in Windows Forms. Therefore, if you want to execute some complicated applications in mono, or port an existing one. net project, you must be very careful.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/lixinye0123/archive/2008/01/20/2054674.aspx