朋友们:.NET跨平台初见端倪

GONGLV 2002-10-08 11:02:48
朋友们:我公司已经从去年开始,将在全国影响较大的一个核心产品成功转为.NET开发,但一直担心跨平台问题,可喜的是,目前已经有一些苗头,我预期的是2002年十一前有商品软件,虽然目前只是一个小小试验品,但足以值得庆贺。

我请大家喝香槟。


Getting Started With C# On Linux
By Rob Blackwell

When Microsoft launched its .NET strategy, one of the objectives was to allow software to be written for a variety of different platforms. It submitted .NET to ECMA for standardization and many people now consider it to be more "open" and accessible than the Java platform.

Miguel de Icaza, the founder of Ximian is working on Mono - an open source implementation of the .NET framework which runs under Linux.

If, like me, you work with Microsoft technologies, but also tinker with Linux, then you can now write C Sharp programs which run on both platforms. This article takes a brief look at Mono and explains how to install the software and start some simple programming.

Head over to www.go-mono.com and download the latest packaged version of Mono. At the time of writing this is mono-0.10.tar.gz

Before you try to build Mono, you need to make sure that you have fairly new versions of the GIMP Toolkit and Drawing Kit, as well as pkg-config. I have a RedHat 7.2 system and I still had to download and upgrade these packages. You can get them from rpmfind.net and install them as follows:

# rpm -Uvh glib2-2.0.0-1.i386.rpm
# rpm -Uvh glib2-devel-2.0.0-1.i386.rpm
# rpm -Uvh pkgconfig-0.12.0-1.i386.rpm
The next step is to unpack the Mono distribution file like this:

# tar -zxvf mono-0.10.tar.gz

To install Mono, change into the newly created mono-0.10 directory and type

# ./configure
# make
# make install
If all goes well, then you should now have a working Mono system including mcs (The Mono C Sharp Compiler suite) , mono (The Mono Just in Time compiler) and mint (The Mono interpreter). All of which now have useful man pages.

Tradition dictates that the first program we should try out is the famous Hello World, and here it is coded in C Sharp.

// Hello World in C Sharp
class Hello {
static void Main() {
System.Console.WriteLine("Hello World");
}
}
C Sharp programs must end in the .cs suffix. Type this file in (using your favourite text editor) and save it to a file Hello.cs then you can compile it using the following command

# mcs Hello.cs

If you've typed everything correctly and there are no syntax errors, this should generate a MSIL file called Hello.exe which you can try out as follows:

# mint Hello.exe
Hello World
The mint interpreter has a number of options including --trace and --debug which are useful for debugging. When your program is finished, you can run it with the JIT compiler to get full performance.

# mono Hello.exe
Hello World
The Common Language Runtime provides cross-platform portability. A .NET application can run on any system for which the CLR has been ported. In fact Mono version 0.10 is the first version to be "self hosting" before that, the Mono C Sharp compiler had to be compiled using the Microsoft .NET Framework SDK on Windows and then moved over to Linux. You can take C Sharp programs compiled on Windows and run them on Linux, but at the time of writing there are still a few problems going from Linux to Windows.

Building GUI applications under Mono is still difficult, but work is underway. The Gtk# project at gtk-sharp.sourceforge.net aims to provide C# language bindings for the gtk+ toolkit. The aim is also to provide a Windows.Forms compatible library under Mono. There are several areas, where moving from Microsoft platforms to Linux may be hard, in particular where Microsoft rely on win32 extensions, HWND and HDC handles etc, but much of this has already been thought through by the team.

Mono is not yet a full implementation of the .NET framework, but there is enough there to start writing some interesting programs. New releases are likely to come thick and fast, and the breadth and quality of the base classes will continue to improve.

Miguel de Icaza has hinted at using Mono for GNOME development. Maybe Mono and .NET will help to bring the open source and Microsoft development communities closer together?

Useful Sites
www.go-mono.com The home of the Mono project
msdn.microsoft.com/net Microsoft .Net Development
www.aws.netActive Web Solution
...全文
76 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧