Novell Home

Novell Connection Magazine Home

From .NET to Linux in Five Easy Steps

  • Audio

If yours is like most IT organizations, today's economic downturn is forcing you to look long and hard at driving down costs, and Linux certainly has significant cost advantages over proprietary operating platforms. That presents a problem for .NET shops. They typically have a repertoire of .NET applications, many of them handling critical business processes. The problem is that .NET applications don't run in the Linux environment.

What's more, organizations deploying .NET have made a considerable investment in developers skilled in .NET and Visual Studio, and pushing these developers outside their Visual Studio comfort zone is costly and involves long learning curves. Hiring new developers with skills in other environments is even more costly, and new developers face a significant learning curve in coming up to speed on the organization's business.

If yours is a .NET shop, Novell has the key that enables you and your organization to leverage .NET applications and Visual Studio skills in Linux environments. How? With Mono and Mono Tools for Visual Studio.

Mono is a software platform that allows you to run .NET applications on other platforms. Sponsored by Novell, Mono is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime. It provides a runtime environment that can execute compiled .NET code on a wide variety of operating platforms, including Linux, UNIX, Mac OS X and even mainframes (a capability unique to Mono).

The Mono Tools for Visual Studio is a new offering for developers targeting the Mono platform. It's a plug-in for Microsoft Visual Studio that enables developers to develop .NET applications for execution on Mono-enabled platforms, all within the developer's preferred development environment—Visual Studio. With Mono Tools for Visual Studio, developers can build, debug and deploy .NET applications targeting other platforms, including Linux, while continuing to leverage the extensive ecosystem of code, libraries and tools available for .NET.

With Mono and Mono Tools for Visual Studio, .NET-skilled developers can easily migrate .NET applications to Linux. What's more, they can develop, debug, test and deploy new .NET applications for Linux as well as other platforms, all without leaving their Visual Studio comfort zone. This article presents a straightforward, five-step process for using Mono and Mono Tools for Visual Studio to move from .NET to Linux. The Mono Tools automate much of the work.

Step 1: Prepare Your Workstation

First, you need to configure your Visual Studio workstation for Mono. To do so, download and install the following software on your Visual Studio workstation:

    Mono Tools
    Goto: http://www.go-mono.com/monotools/ and download and install Mono Tools. This Visual Studio plug-in adds a Mono command and drop-down menu to the Visual Studio menu bar. (See Figure 1.)

    Mono 2.4 (or later)
    Goto: http://www.go-mono.com/mono-downloads/download.html and download and install the latest version of Mono for Windows. This also installs the Mono xsp development Web server. This step supports the Run Locally in Mono command on the Mono drop-down menu.

    VMware Player or Virtual PC
    You will need to install either VMware or Virtual PC to run Linux and MonoVS server on your workstation. (The Mono Project recommends VMware.) Goto: www.vmware.com or www.microsoft.com/windows/virtual-pcand and download and install the hypervisor you prefer.

    MonoVS Server
    Goto: http://www.go-mono.com/monotools/download/ and download and unzip the MonoTools Server image for either VMware or Virtual PC. This image contains openSUSE, Apache 2 and Mono for Linux configured for one of the two supported hypervisors.

    This step supports the Run Remotely in Mono, Debug Remotely in Mono and Create Linux Package for Project commands on the Mono drop-down menu.

You are now ready to migrate your .NET applications to Linux.

Step 2: Analyze the Application with MoMA

In this step, you use the Mono Migration Analyzer (MoMA) to analyze your application to identify any incompatibilities between .NET and Mono.

Subscribe to Connection Magazine


For example, MoMA identifies platform-specific calls, such as P/Invoke, and other areas that are not yet supported by Mono. You will have to address these incompatibilities in the course of migrating your .NET application to Mono.

MoMA identifies the source of each incompatibility in a detailed report that you can use to estimate the effort required to migrate the application to Linux. Of course, not all .NET applications can be easily migrated. However, of the thousands of .NET applications that have been analyzed with MoMA, the vast majority could be migrated, most with little or no modification.

To analyze a .NET application, you first load it and its project files into Visual Studio. Then, you analyze it using MoMA. To do so, select Analyze for Mono Migration (MoMA) on the Mono drop-down menu.

MoMA will build the solution, analyze it, and report errors, warnings, and informational messages in the Visual Studio Error List window. The issues will be rated. Clicking on an issue causes Visual Studio to jump to the affected code.

In most cases, you can quickly clear the issues identified by MoMA using Visual Studio Editor. When you have addressed all incompatibility issues identified by MoMA, you are ready to move to the next step.

Step 3: Run the Application Locally

While the MoMA tool is comprehensive, some issues may not show up until runtime. Consequently, Novell recommends that, after you analyze your application with MoMA and address all identified issues, you run it locally on your Windows workstation using Mono. To do so, Select Run Locally in Mono on the Mono drop-down menu. This runs the application on Mono for Windows which you installed in Step 1.

Running locally on Mono permits you to focus on incompatibilities between Mono and .NET. In the next step, you'll eliminate any differences between running on Windows and running on Linux.

Remaining incompatibilities between Mono and .NET will likely manifest as application crashes or inconsistencies in user experience and behavior occur. Crashes usually generate stack traces with line numbers indicating where the exceptions occurred in code. Using the stack traces and Visual Studio Editor, rewrite any error-causing sections of the application code and run it locally on Mono again. Continue until you can run the application without error.

When you have addressed all incompatibilities, you are ready to move to the next step which is to run the application on a remote Linux machine.

Next

  • Figure 1

    Mono Tools adds a Mono command and drop-down menu to the Visual Studio menu bar.

  • Figure 2

    To select the remote Linux host on which you wish to run and debug your .NET application, click on that host in the MonoVS, choose Remote Host dialog and then click OK.

  • Figure 3

    When you are running a .NET application on a remote Linux host, a balloon will appear over the MonoVS application icon in your workstation system tray, indicating that a remote instance of the application is running.

  • Figure 4

    You can invoke the SUSE Studio Appliance Wizard-a Novell sponsored online service-to create a software, virtual or hardware appliance. The wizard will take you though the necessary steps to build the appliance.



© 2014 Novell