Porting .NET applications
to Linux

Bill Bodine

Software Engineering Consultant

Novell

.NET ?

What is .NET ?

Application development framework from Microsoft

Spawns across all of Microsoft's offering, umbrella marketing

.NET Applications:

Usually built in VS.NET on Windows

Runs on the .NET VM (compiled to MSIL)

Uses the .NET core libraries

Will likely use managed code

Might make calls to different APIs (System.Windows.Forms, ADO.NET, XML, ...)

Might make native calls (Platform Invokes)

May use third party controls

Console, GUI (SWF, GTK#, VxWorks, ...), or Web applications and also Web Services

.NET

Multi-language support,
multi-architecture support

C#

Fortran

Eiffel

C++

JavaScript

Visual Basic

Java

Cobol

x86

SPARC

StrongARM

s390

PowerPC

Common

Intermediate

Language

Code Generation:

Just-in-Time

or Ahead-of-Time

.NET

European Computer Manufacturers Association - ECMA

C#

CLR

C++/CLI

.NET

.NET 1.1

C#

CLR

C++/CLI

VB.NET

Windows

.Forms

Enterprise

Services

XML

ASP.NET

ADO.NET

.NET, .NET or .NET ?

Microsoft Software Ecosystem

.NET Universe

C#

CLR

C++/CLI

VB.NET

Windows

.Forms

Enterprise

Services

XML

ASP.NET

ADO.NET

MS-SQL

IIS

Exchange

Compact

Framework

MSI

& SMS

Passport,

IM,

...

3rd

Parties

Mono™ ?

What is Mono ?

Open source effort sponsored by Novell

Implementation of the .NET development framework

Includes:

C# compiler

CLR (.NET Virtual Machine)

Set of APIs (.NET and Linux/Gnome bindings)

ADO.NET & ASP.NET for web application and web services development

Embedding API (Perl, C, C++, …)

And more… (Java, VB.NET, …)

What is Mono ?

End User Applications

IDE, Debuggers, Profilers

Operating System

ECMA Virtual Machine (.NET or Mono)

ECMA Foundation Class Libraries

Compilers:

C#, Jscript, VB.NET, Java, ...

GUI toolkits APIs

(Windows.Forms,

GTK#)

ADO.NET

ASP.NET

(Web Applications,

Web Services)

Linux Bindings

ASP.NET

Evolution#

Mono Runtime

What is Mono ?

(Implementation of ECMA #335)

MySQL/Postgress

Novell iFolder

Mozilla

GTK#

Apache Mono

Gnome#

Novell LDAP

ZipLib

Java Compatibility

ADO.NET

Windows.Form

Microsoft Compatibility Libraries

Mono Libraries

Novell Software Ecosystem

OpenOffice

Evolution

Mozilla

Linux

Desktop

eDirectory™

GroupWise®

Third Party

.NET

Mono

One problem at a time…

.NET binaries and Mono

Mono is binary compatible with Microsoft .NET

runs .NET .exe and DLLs

but only .NET ones, not win32 ones

You can re-compile with mcs but you don't need to

What you'll find in your Mono directory:

.exe files (mono application.exe)

.dll files

Shared libraries

Mapping files

Mono includes GAC (Global Assembly Cache) support

Protection from DLL-Hell

C#

Mono 1.0 includes a C# 1.0 compiler and C# 2.1 extensions (generics in beta)

Mono 2.0 will include a C# 2.1 compiler

Current CVS includes generics and anonymous method supports.

C# is the language of choice even though the CLR is multi-language

C#

VB.NET

VB.NET compiler and runtime in current CVS

Final release with Mono 1.4 (Feb 2005)

Can run ASP.NET pages since August 2004

Key to migration efforts

Perception: Most VB6 developers are adopting VB.NET

VB.NET

ADO.NET & Databases

Regardless of what it does, your application is likely to make DB access

Complete implementation of ADO.NET in Mono 1.0

Includes data providers for Oracle, MS-SQL Server, MySQL, Progress…

Possible to migrate from MS-SQL to MySQL (for example) but not necessary

Migration Applications (MSSQL-to-MySQL)

Migration guides http://dev.mysql.com/tech-resources/articles/migrating-from-microsoft.html

Also available, Gda# & GnomeDB#

Data access via Soap/Web (then use System.Web.Services and System.XML) or Remoting

System.Windows.Forms

Mono 1.2 (Feb 2005) will include SWF compatibility

Essential to seamless migration of classics Windows .NET GUI applications

Gtk#

Set of .NET bindings for the gtk+toolkit and assorted GNOME libraries

Allows you to build fully native Gnome application using Mono and includes support for user interfaces built with the Glade interface builder.

Cross platform (Linux, Windows, MacOS X, Solaris, …)

True .NET API, not just a wrapper to C++ bindings

System.Windows.Forms or Gtk# ?

ASP.NET

Mono includes support for ASP.NET (Web Applications and Web Services)

XSP

Standalone server

ASP.NET & static HTML only

Development time

Back-end for mod_mono

mod_mono

Plugin for Apache (v1&v2)

Uses Apache for all common web server tasks

Unix sockets communication

ASP.NET

Language support

Most applications use VB.NET or C#

Need for a Code Provider for additional language support

C# with Mono 1.0

VB.NET with Mono 1.2 (February)

Pages compiled at runtime

ASP.NET 2.0 includes Pre-compiled pages support

Careful of IIS specific programming outside of ASP.NET

Web Services, remoting, …

Third Party controls

P/Invoke

Platform Invocation services : Native calls

Trivial to use

Unsafe Code, leaving the sandbox safety

Opportunity for platform inconsistencies

Does the native code you invoke in Windows exist in Linux?

IDEs

MonoDevelop

http://www.monodevelop.com

Eclipse

Emacs, VIM, …

VisualStudio.NET

IDE

Migration
10 rules to make it work

Top 10 rules for migration

Never, ever, ever use the \ to separate directories when doing any file I/O. Instead, use the System.IO.Path.DirectorySeparatorChar constant. This translates directly over to the *nix world and makes for a smooth transition in Mono.

You can also just use Path.Combine( path1, path2 ) to combine two strings together and get a file path out of it. It's a much more useful method if you don't know if your paths have leading/trailing PathSeparatorChars.

Rule

#1

Top 10 rules for migration

Just as most of us have learned case sensitivity in .NET, carry this forward to your file I/O operations, again, and make sure all files and directories are case sensitive.

Rule

#2

Rule

#3

Top 10 rules for migration

Make sure you don't compile your assemblies with the /incremental flag. Mono can't support incremental compilation.

For more details on what "incremental compilation" is, see: http://msdn.microsoft.com/library/default.asp?url=/library/en-s/cscomp/html/vcgrfincrementalenableincrementalcompilation.asp

Top 10 rules for migration

That’s it for rules.

Mono this, Mono that

Mono@Novell

Novell Sponsored project

23 developers

Used at Novell by many projects

NLD, Novell iFolder®, iPrint, VO, ZLM Update Manager
(Formerly Red Carpet)

Mono Support & Consulting offered by Novell

Mono Migration Success Stories

City of Munich: ASP.NET

350 servers, 150,000 users.

SourceGear: Vault Software 2.0

Web Services Client to Microsoft .NET

MonoDevelop IDE

Ported from Windows in record time.

Novell iFolder

Cross platform development.

Apr May Jun

Jan Feb Mar

Oct Nov Dec

Jul Aug Sep

Apr May Jun

Jan Feb Mar

Jul Aug Sep

Mono
Roadmap (calendar quarters)

Apr May Jun

3Q04

2Q04

Oct Nov Dec

2Q05

1Q05

4Q04

FCS Date

Beta Date

3Q05

2Q06

1Q06

4Q05

Jan Feb Mar

1Q04

Dec

June

Mono 1.0

Open Source multi-platform .NET implementation

Gtk# 1.0, Java IKVM

Core tools (C# Compiler, Runtime, Debugger,MonoDoc)

Supported deployment on Linux (PPC & x86), Windows and MacOS X

Establishes parity with Microsoft .NET 1.1

Mono 1.4

Implementation of Windows.Forms

Preview of .NET 2.0 features:

ASP.NET 2.0 & XML 2.0

C# 2.0

VB.NET 1.0

GTK# updated for Gnome 2.6 APIs and data bindings support.

Mono 2.0

Establishes parity with Microsoft .NET 2.0

ASP.NET 2.0

XML 2.0

C# 2.1

Update of Mono Exclusive APIs

Preview of select Longhorn features

Dec

Q1

Q3

Mono 1.2

Performance Optimizations

Bug fixes

Mono - A Developer’s Handbook

“All labs, no lectures”

O’Reilly Publishing

More Mono

http://www.mono-project.com

mono@ximian.com

Communicate benefits, not features.

Insert “target sunset date” for each release. This is the date that will begin the process to remove the product from market.

2003-12-08T12:43:39