Mono first experience

xiaoxiao2021-03-05  19

Mono first experience

Recently. Net community is very enthusiastic to Mono, which is also a by-product of Microsoft .NET strategy. Mono's current main battlefield is still on Linux, but I am a pure Windows programmer, lazy to configure a Linux environment, so I am not free to go to Mono, I found a Windows installer, so I downloaded a mono 1.0 .6 for windows. The path download is: http://www.mono-project.com/downloads

After the installation is complete, select Mono Command Prompt in the Start menu, and return to the command line era. People who have used Java should be unfamiliar with Mono's compilation and implementation. Compilation is MCS and executes is Mono. So I started writing the first program in the example of the previous person:

Using system;

Namespace mynamespace

{

Public Class Hellowolf

{

Public static void main (string [] args)

{

Console.writeline ("Hello, Wolf!");

}

}

}

Save as Hellowolf.cs and enter: MCS Hellowolf.cs in the command line. Compilation, then execute Mono Hellowolf.exe, everything is normal. I tried directly to enter Hellowolf.exe, ha, actually running normally, is Mono's IL and .NET Framework is compatible? This problem needs to be studied.

Ok, let's write a window. There is no System.Windows namespace, but use a space called GTK, and write the following code, save it to mymain.cs.

// mymain.cs

// Copyright (C) 2005, AAWOLF

//

Using system;

Using gtk;

Namespace Wolfdemo

{

Public class mymain

{

Private gtk.window window;

Public static void main (string [] args)

{

Application.init ();

New mymain ();

Application.run ();

}

Public mymain ()

{

Window = New gtk.window ("GTK # code Demos");

Window.SetDefaultsize (600, 400);

Window.deleteEvent = New deleteEventHandler (Windowdelete);

WINDOW.SHOWALL ();

}

Private Void WINDOWDELETE (Object O, DeleteEventArgs Args)

{

Application.quit ();

Args.retval = true;

}

}

}

Ok, the case is performed, but this error, the prompt can't find GTK. I got some work for this, and finally I found a file called gtk-sharp.dll under x: / mono / lib / mono / gtk-sharpe. Dare to determine whether it is, so I looked with the Reflector, prove that the GTK namespace did contain GTK namespace.

So: mcs mymain.cs -r: d: /monob/lib/mono/gtk-sharp/gtk-sharp.dll

Ok, this time I finally compiled, execute Mono mymain.exe, so Mono's first window appeared. Try directly to run mymain.exe, this time is VS JIT Debugger, after all. Net framework, there is no GTK. Ok, the first time this looks almost, look back slowly study J

转载请注明原文地址:https://www.9cbs.com/read-38693.html

New Post(0)