试用mono(一)导入VS.Net篇

第一次使用mono的时候已然不记得是什么时候了,当时只知道有一个东西,貌似能够模拟.Net的程序。当时我用的是RH9,从mono的official site下载了好多rpm包,一个一个安装上。我记得效果不太好,只能运行Console项目,GUI的没法运行。ASP的项目倒也是可以,不过很容易出错。

最近需要将一个C#的项目移植到linux下,用C语言 重写,所以一条一条的翻译。最好能够在linux下面实时运行C#程序,对比运行结果。于是我想到了mono这个东东。

在这里,作为一个debianer ,又一次想吹嘘一下debian。一个apt-get就搞定了所有的mono依赖关系,而且保证是最新的。先预报一下版本:我的debian是unstable,$ dpkg -l |grep mono
ii libmono-accessibility1.0-cil 1.2.2.1-1 Mono Accessibility library
ii libmono-accessibility2.0-cil 1.2.2.1-1 Mono Accessibility library
ii libmono-cairo1.0-cil 1.2.2.1-1 Mono Cairo library
ii libmono-cecil0.4-cil 0.4.3-1 library to generate and inspect CIL assembli
ii libmono-corlib1.0-cil 1.2.2.1-1 Mono core library (1.0)
ii libmono-corlib2.0-cil 1.2.2.1-1 Mono core library (2.0)
ii libmono-data-tds1.0-cil 1.2.2.1-1 Mono Data library
ii libmono-data-tds2.0-cil 1.2.2.1-1 Mono Data Library
ii libmono-ldap1.0-cil 1.2.2.1-1 Mono LDAP library
ii libmono-ldap2.0-cil 1.2.2.1-1 Mono LDAP library
ii libmono-microsoft-build2.0-cil 1.2.2.1-1 Mono Microsoft.Build libraries
ii libmono-peapi1.0-cil 1.2.2.1-1 Mono PEAPI library
ii libmono-peapi2.0-cil 1.2.2.1-1 Mono PEAPI library
ii libmono-relaxng1.0-cil 1.2.2.1-1 Mono Relaxng library
ii libmono-security1.0-cil 1.2.2.1-1 Mono Security library
ii libmono-security2.0-cil 1.2.2.1-1 Mono Security library
ii libmono-sharpzip0.84-cil 1.2.2.1-1 Mono SharpZipLib library
ii libmono-sharpzip2.84-cil 1.2.2.1-1 Mono SharpZipLib library
ii libmono-system-data1.0-cil 1.2.2.1-1 Mono System.Data library
ii libmono-system-data2.0-cil 1.2.2.1-1 Mono System.Data Library
ii libmono-system-ldap1.0-cil 1.2.2.1-1 Mono System.DirectoryServices library
ii libmono-system-ldap2.0-cil 1.2.2.1-1 Mono System.DirectoryServices library
ii libmono-system-messaging1.0-cil 1.2.2.1-1 Mono System.Messaging library
ii libmono-system-messaging2.0-cil 1.2.2.1-1 Mono System.Messaging Library
ii libmono-system-runtime1.0-cil 1.2.2.1-1 Mono System.Runtime library
ii libmono-system-runtime2.0-cil 1.2.2.1-1 Mono System.Runtime Library
ii libmono-system-web1.0-cil 1.2.2.1-1 Mono System.Web library
ii libmono-system-web2.0-cil 1.2.2.1-1 Mono System.Web Library
ii libmono-system1.0-cil 1.2.2.1-1 Mono System libraries (1.0)
ii libmono-system2.0-cil 1.2.2.1-1 Mono System libraries (2.0)
ii libmono-winforms1.0-cil 1.2.2.1-1 Mono System.Windows.Forms library
ii libmono-winforms2.0-cil 1.2.2.1-1 Mono System.Windows.Forms library
ii libmono0 1.2.2.1-1 libraries for the Mono JIT
ii libmono1.0-cil 1.2.2.1-1 Mono libraries (1.0)
ii libmono2.0-cil 1.2.2.1-1 Mono libraries (2.0)
ii mono 1.2.2.1-1 Mono CLI (.NET) runtime
ii mono-common 1.2.2.1-1 common files for Mono
ii mono-gac 1.2.2.1-1 Mono GAC tool
ii mono-gmcs 1.2.2.1-1 Mono C# 2.0 compiler
ii mono-jit 1.2.2.1-1 fast CLI JIT/AOT compiler for Mono
ii mono-mcs 1.2.2.1-1 Mono C# compiler
ii mono-runtime 1.2.2.1-1 Mono runtime
ii mono-utils 1.2.2.1-1 Mono utilities
ii mono-xsp 1.2.1-1 simple web server to run ASP.NET application
ii mono-xsp-base 1.2.1-1 base libraries for XSP 1.1
ii mono-xsp2 1.2.1-1 simple web server to run ASP.NET application
ii mono-xsp2-base 1.2.1-1 base libraries for XSP 2.0
ii monodevelop 0.12+dfsg-1 C#/Boo/Java/Nemerle/ILasm/ASP.NET Developmen
ii monodoc-base 1.1.18-1 shared MonoDoc binaries
ii monodoc-manual 1.1.18-1 compiled XML documentation from the Mono pro
以上就是我安装的mono全部组件了。在gnome的菜单Applications->Programming->MonoDevelp,这就是mono的开发环境了。

Welcome - MonoDevelop

和VS.Net的欢迎界面挺像的。

好,从我要干的活开始说起,我要运行一个已经完成的VS.Net2003 项目,带有GUI的。可以选择File -> Import Visual Studio .Net Project,找到VS.Net项目的sln文件后,系统会提示顺利导入。

Import MonoDevelop.png

这样,我们就可以打开这个项目,进行操作了。总体来说,除了不能进行所见即所得 的控件操作之外,编辑方面都算是不错,特别还保留了VS .Net的自动补全功能,这点应该加分。

接下来是编译和运行,这部分mono做得也不错,可以直接从项目生成exe文件执行。但是美中不足的是现在mono的release版本不支持实时调试,在调编译选项中使用debug选项只能在运行时打印出异常的位置和信息。mono的调式工具Mono Debugger 正在开发中,现在可以使用GDB将就一下。

运行结果没有问题,一切正常,看来mono在程序运行这部分应该比较成熟了。

GUI Form

5 thoughts on “试用mono(一)导入VS.Net篇

  1. Microsoft .NETThe .NET Framework created by Microsoft is a software development platform focused on rapid application development (RAD), platform independence and network transparency. .NET is Microsoft's strategic initiative for server and desktop development for the next decade. According to Microsoft, .NET includes many technologies that are designed to facilitate rapid development of Internet and intranet applications.

Leave a Comment

Your email address will not be published. Required fields are marked *