guolii在google sites

本网站的结构

本网站的结构(网站地图也就是sitemap)大致如下:
首页是sites.google.com/site/guolii2005;
各个网页左边总有“导航”区,“导航”就像网站的“导游”;
网站主要内容是日记(博客)、网址收藏、大杂烩;
日记分类了,有家庭、基督、工作、自由软件。。。
日记‎ > ‎自由软件‎ > ‎

用跨平台的Mono学习C#

发布者:? ?,发布时间:2008-10-28 上午1:18   [ 更新时间:2008-11-26 上午1:47 ]

从源代码安装Mono 2.0.x

单位要用.NET,没办法,必须学习,先用跨平台的Mono学习看看。

Mono 2.0支持:

Run ASP.NET, ADO.NET, and Windows.Forms 2.0 applications without recompilation

Develop in C# 3.0 (including LINQ), VB 8, Java, Python, Ruby (http://www.ironruby.net/), Eiffel (http://www.eiffel.com/), F# (http://research.microsoft.com/fsharp/), Oxygene (http://remobjects.com/oxygene), and more

Installing Mono 2.0.1

Binary Packages and Source Code Downloads:

Source code and pre-compiled packages for Linux, Solaris, 
MacOS X and Windows is available from our web site from
the Downloads section.

Quick source code installation:

If we have no packages for your platform, installing from 
source code is very simple.

Compile libgdiplus to support System.Drawing:

    $ tar xzf libgdiplus-2.0.tar.gz
$ cd libgdiplus-2.0
$ ./configure
$ make
$ make install

Then compile Mono itself:

    $ tar xzf mono-2.0.1.tar.gz
$ cd mono-2.0.1
$ ./configure
$ make
$ make install

Console Hello World

To test the most basic functionality available, copy the following code into a file called hello.cs.

using System;
 
public class HelloWorld
{
static public void Main ()
{
Console.WriteLine ("Hello Mono World");
}
 
}

To compile, use mcs:

mcs hello.cs

Using mcs to compile produces a .Net 1.1 assembly. To create a .Net 2.0 assembly, use gmcs:

gmcs hello.cs

Either compiler will create "hello.exe", which you can run using:

mono hello.exe

The program should run and output:

Hello Mono World

Winforms Hello World

The following program tests writing a Winforms application.

using System;
using System.Windows.Forms;
 
public class HelloWorld : Form
{
static public void Main ()
{
Application.Run (new HelloWorld ());
}
 
public HelloWorld ()
{
Text = "Hello Mono World";
}
}

To compile, use mcs as well as the -pkg command to tell the compiler to pull in the Winforms libraries:

mcs hello.cs -pkg:dotnet

Using mcs to compile produces a .Net 1.1 assembly. To create a .Net 2.0 assembly, use gmcs:

gmcs hello.cs -pkg:dotnet

Either compiler will create "hello.exe", which you can run using:

mono hello.exe
我的ubuntu linux还需要运行sudo ldconfig才能运行Winforms Hello World

Why? 俺搞不定从源代码编译安装Monodevelop IDE!

用ubuntu安装已有的软件包先学习着再说!
安装monodevelop就是。
学asp.net还要装mono-xsp2:
XSP is a simple web server written in C# that can be used to run your
ASP.NET 1.1 and 2.0 applications.

下个月以后用opensuse11.1 linux正式版看看,有最新的mono2.0.x;fedora linux10说不定也有最新的mono环境。