Get Started with Mono

Share this article

Here’s a disclaimer: I avoid Linux and am no Linux expert by any means. I shudder at the thought of black screens with a flashing cursor. I find myself moving my mouse around trying to find an icon to click or a menu to select.

It’s from such a perspective that this article will demonstrate how anyone (even I!) can get Mono up and running on a fresh, clean Linux box. I’ll walk through my experience of installing the package, and discuss all the components needed to run Mono.

What Is Mono?

Mono is an open source project used to code much of the .NET framework in cross-platform executable code. Sponsored by Novell, Mono gives developers the chance to develop ASP.NET and Windows Forms applications not only for Windows, but now, principally, for Linux.

While they’re not yet complete, applications written for the standard Microsoft .NET framework can now be ported and run on Linux through Mono. However, holes within the framework implementation on Mono mean you’ll still need to check that your application doesn’t use any services that are not yet implemented.

What’s Usable in Mono?

Currently, Mono is in development, but the project has reached some significant milestones that make it suitable and stable enough for deployment today. The C# compiler is the only fully featured compiler for Mono. Yes, that’s right: VB.NET and J# developers will need to switch to C# to fully use Mono. Watch the progress of the VB.NET compiler here.

The compiler itself is written in C#. You can download all 1.7 million lines of C# code and compile this yourself, or, as we’ll see shortly, you can use one of the many distributions to ease the installation process.

ASP.NET is fully-featured and supported within Mono. In fact, it’s the great strength of Mono at present. You can build and deploy both Web forms and Web services using either the built-in Web server that ships with Mono (XSP) or through an Apache modification, Mod Mono. For those who are uncomfortable using Windows and IIS to host applications, Mono provides a viable alternative.

Windows Forms is currently under development, but functionality is progressing. Though complex WinForm applications, such as Web Matrix, are currently unavailable, there are alternatives to WinForms in Mono that build GUI applications. Gtk# and #WT are wrappers to the popular GUI tools on Linux. WinForms itself is being built as a library extension to Wine, the Win32 implementation on Linux. The project’s progress is documented here.

ADO.NET and the System.Data classes are also fairly mature; however, they aren’t at production level at the time of writing. This is one of the largest projects within Mono, and at present you can connect to a wide variety of databases. Native support is provided for many of the databases usually associated with Linux, such as PostgreSQL.

Mono has successfully been used in commercial and heavy-use applications. Novell used the tool to build two of its products, iFolder and ZenWorks. Also, SourceGear has used Web services deployed in Mono within its Vault application.

Getting Started: Download Mono

Mono is available in many packages. You can download the latest source code build and a daily snapshot source code build, through CVS, an RPM package, or a Red Carpet install for those with Xiamian Desktop. By far the easiest to use is the Red Carpet system, which, while similar to RPM, offers good versioning control, allowing you to upgrade Mono on your machine very easily.

The Mono download page details the various packages and how they can be downloaded, as well as specific packages for specific varieties of Linux.

http://www.mono-project.com/downloads/

I downloaded the Mono Runtime tarball and used the following command to unpack the distribution:

tar -zxvf mono-1.0.tar.gz

Once the tarball was extracted, I could start the installation process using:

./configure
make
make install

It was at this point I realised I needed to upgrade pkg-config on the system as the installation spat out some errors. I found the RPM distribution for this, and installed it using the following command:

rpm -Uvh pkgconfig-0.15.0-4mdk.i586.rpm

The make process now worked without a hitch.

Hello World in C# Running on Linux

It’s always a good thing to use the cliched “Hello World” example to test an installation!

Open your favourite Linux text editor (I used vi) and enter the following simple C# application code:

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

Save this file as HelloWorld.cs and compile the class with the Mono C# compiler:

mcs HelloWorld.cs

In the directory to which you saved HelloWorld.cs, you should now see a HelloWorld.exe file. This is standard MSIL code that can be executed on any computer on which the .NET framework is installed, including Windows.

There are two ways to run Mono applications. One method is to use “mint,” which is an interpreter for the MSIL bytecode. Mint does not compile and run your applications into native machine code, hence it is not a JIT runtime. “Mono” however is a JIT runtime, which compiles bytecode when first requested into machine code native for the platform and processor for which it was designed.

This means that, for performance, the Mono application is much faster than mint, though it’s not as portable as it is tied to the particular operating system. Mint, on the other hand, is far more portable and, as it’s written in ANSI C, may be used on a multitude of deployment platforms.

To run our Hello World application, we can use the following command, which invokes Mono:

mono hello.exe

We use the following command to invoke mint:

mint hello.exe
Dishing Up ASP.NET

Mono comes with its own Web server, ready to dish out your ASP.NET applications. Mono. XSP is very easy to use and makes for a simple ASP.NET Web server that is almost akin to the Cassini server that ships with Web Matrix on Windows. For more dominance, you can download a module called mod_mono that allows Apache to support ASP.NET. In this article, however, we’ll examine the formation of a simple Web application and host it using XSP.

I must admit that I cheated when I created the code for the Web application: I used Visual Studio to create the Web application and its associated files. Then, I copied the code over to the Linux box that was ready to host.

For our example, we’ll create a Web page with a simple button and a label. When the button is clicked, the label will show that the user clicked the button.

<%@ Page Language="C#" %>  
<script runat="server">  

void Button1_Click(object sender, EventArgs e)  
{  
  titleTag.InnerText = "You clicked the button!";  
}  

void Page_Load(object sender, EventArgs e)  
{  
  if (!IsPostBack)  
    titleTag.InnerText = "Page has loaded";  
}  

</script>  
<html>  
<head>  
<title runat="server" id="titleTag"/>  
</head>  
<body>  
<form runat="server">  
  <asp:Button id="Button1" OnClick="Button1_Click" runat="server" Text="Button"/>  
</form>  
</body>  
</html>

You can save this file to a directory that will act as your root for the Web application.

If you are using codebehinds for your application, you will also need to compile the source files using the Mono compiler, in order to obtain the compiled assembly for the application. Just as with ASP.NET on Windows, you’ll need to drop this into a /bin directory on the root.

XSP, by default, listens on the 8080 port so as to not interfere with Apache; however, you can set up the server, via the command line, to listen at a different port. You can also specify the root directory of the application you wish to host:

xsp.exe  [--root rootdir]  
               [--port N]

With the server running, you can access your page through any standard Web browser. And, there we have it: ASP.NET served over Linux!

Third Party Tools

There are numerous tools available to aid your developments in Mono so that, unlike me, you don’t need to resort back to Visual Studio.

  • MonoDevelop: With GUI features still lacking in Mono, MonoDevelop is really pushing the current implementations to show what can be achieved in Mono. Resembling #develop for Windows, MonoDevelop supports syntax highlighting and the compilation of projects from an easy-to-use interface. However, this tool is still at an early stage of development and presently lacks the features needed to make it a truly useful instrument.
  • Eclipse: Billed as “a kind of universal tool platform — an open extensible IDE for anything and nothing in particular,” Eclipse is a great solution for developing Mono applications. By downloading and installing the Improve C# plugin for Eclipse you can have a fully-featured and free Java based IDE for your Mono developments.
  • MonoDoc: This is a browser for the Mono documentation. It isn’t installed by default through the standard Mono packages, but it is a life saver for those needing to check whether certain APIs and parts of the framework are available in Mono.
Summary

From my study of Mono, I’ve come to understand that this is a very important project for .NET. The release of .NET from the confines of Microsoft operating systems will allow it to expand within communities that are normally off-limits to Microsoft technologies.

Mono can only grow stronger, and perhaps in the near future, .NET developers will be able to develop for Linux as easy as we develop for Windows today.

Frequently Asked Questions about Getting Started with Mono

What is Mono and why is it important in software development?

Mono is an open-source platform that allows developers to build cross-platform applications with .NET. It is important in software development because it provides the necessary tools to develop and run .NET client and server applications on different platforms such as Linux, Windows, and Mac. This means that developers can write a single application that can run on multiple platforms, reducing the time and effort required to develop separate applications for each platform.

How does Mono compare to .NET Core?

While both Mono and .NET Core allow for cross-platform development, there are some key differences. Mono is a full-stack framework that includes everything from the runtime to the GUI toolkit, while .NET Core is a modular framework that allows developers to pick and choose the components they need. Additionally, Mono supports more platforms than .NET Core, including older versions of Windows and some game consoles.

How can I install Mono on my system?

Installing Mono on your system is a straightforward process. You can download the latest stable release from the Mono project’s official website. Once downloaded, you can follow the installation instructions provided for your specific operating system. It’s important to note that Mono requires certain dependencies to be installed on your system, so make sure to check the requirements before installing.

What programming languages are supported by Mono?

Mono supports a wide range of programming languages, including C#, F#, Visual Basic.NET, and more. This makes it a versatile tool for developers who work with different programming languages.

Can I use Mono to develop mobile applications?

Yes, you can use Mono to develop mobile applications. Xamarin, a popular mobile app development platform, is built on Mono. This means you can use C# and .NET to build apps for iOS, Android, and Windows.

What are some common issues developers face when using Mono?

Some common issues developers face when using Mono include compatibility issues with .NET, performance issues, and lack of support for some .NET features. However, the Mono community is active and constantly working to improve the platform and address these issues.

How can I contribute to the Mono project?

As an open-source project, Mono welcomes contributions from developers. You can contribute by submitting bug reports, proposing new features, or contributing code. You can find more information on how to contribute on the Mono project’s official website.

Is Mono suitable for enterprise-level applications?

Yes, Mono is suitable for enterprise-level applications. It provides a robust and scalable platform for developing and running .NET applications on multiple platforms. Many large companies use Mono for their software development needs.

Can I use Mono with my existing .NET codebase?

Yes, you can use Mono with your existing .NET codebase. Mono aims to be compatible with .NET, so you can use it to run your existing .NET applications on different platforms.

What is the future of Mono?

The future of Mono looks promising. With the acquisition of Xamarin by Microsoft, Mono has gained more recognition and support. The Mono project continues to evolve and improve, with new features and improvements being added regularly.

Philip MiseldinePhilip Miseldine
View Author

Philip is a Computer Science PhD student at Liverpool John Moores University. He's still not mastered guitar tabs, never finished Mario, and needs a haircut.

Share this article
Read Next
Cloud Native: How Ampere Is Improving Nightly Arm64 Builds
Cloud Native: How Ampere Is Improving Nightly Arm64 Builds
Dave NearyAaron Williams
How to Create Content in WordPress with AI
How to Create Content in WordPress with AI
Çağdaş Dağ
A Beginner’s Guide to Setting Up a Project in Laravel
A Beginner’s Guide to Setting Up a Project in Laravel
Claudio Ribeiro
Enhancing DevSecOps Workflows with Generative AI: A Comprehensive Guide
Enhancing DevSecOps Workflows with Generative AI: A Comprehensive Guide
Gitlab
Creating Fluid Typography with the CSS clamp() Function
Creating Fluid Typography with the CSS clamp() Function
Daine Mawer
Comparing Full Stack and Headless CMS Platforms
Comparing Full Stack and Headless CMS Platforms
Vultr
7 Easy Ways to Make a Magento 2 Website Faster
7 Easy Ways to Make a Magento 2 Website Faster
Konstantin Gerasimov
Powerful React Form Builders to Consider in 2024
Powerful React Form Builders to Consider in 2024
Femi Akinyemi
Quick Tip: How to Animate Text Gradients and Patterns in CSS
Quick Tip: How to Animate Text Gradients and Patterns in CSS
Ralph Mason
Sending Email Using Node.js
Sending Email Using Node.js
Craig Buckler
Creating a Navbar in React
Creating a Navbar in React
Vidura Senevirathne
A Complete Guide to CSS Logical Properties, with Cheat Sheet
A Complete Guide to CSS Logical Properties, with Cheat Sheet
Ralph Mason
Using JSON Web Tokens with Node.js
Using JSON Web Tokens with Node.js
Lakindu Hewawasam
How to Build a Simple Web Server with Node.js
How to Build a Simple Web Server with Node.js
Chameera Dulanga
Building a Digital Fortress: How to Strengthen DNS Against DDoS Attacks?
Building a Digital Fortress: How to Strengthen DNS Against DDoS Attacks?
Beloslava Petrova
Crafting Interactive Scatter Plots with Plotly
Crafting Interactive Scatter Plots with Plotly
Binara Prabhanga
GenAI: How to Reduce Cost with Prompt Compression Techniques
GenAI: How to Reduce Cost with Prompt Compression Techniques
Suvoraj Biswas
How to Use jQuery’s ajax() Function for Asynchronous HTTP Requests
How to Use jQuery’s ajax() Function for Asynchronous HTTP Requests
Aurelio De RosaMaria Antonietta Perna
Quick Tip: How to Align Column Rows with CSS Subgrid
Quick Tip: How to Align Column Rows with CSS Subgrid
Ralph Mason
15 Top Web Design Tools & Resources To Try in 2024
15 Top Web Design Tools & Resources To Try in 2024
SitePoint Sponsors
7 Simple Rules for Better Data Visualization
7 Simple Rules for Better Data Visualization
Mariia Merkulova
Cloudways Autonomous: Fully-Managed Scalable WordPress Hosting
Cloudways Autonomous: Fully-Managed Scalable WordPress Hosting
SitePoint Team
Best Programming Language for AI
Best Programming Language for AI
Lucero del Alba
Quick Tip: How to Add Gradient Effects and Patterns to Text
Quick Tip: How to Add Gradient Effects and Patterns to Text
Ralph Mason
Logging Made Easy: A Beginner’s Guide to Winston in Node.js
Logging Made Easy: A Beginner’s Guide to Winston in Node.js
Vultr
How to Optimize Website Content for Featured Snippets
How to Optimize Website Content for Featured Snippets
Dipen Visavadiya
Psychology and UX: Decoding the Science Behind User Clicks
Psychology and UX: Decoding the Science Behind User Clicks
Tanya Kumari
Build a Full-stack App with Node.js and htmx
Build a Full-stack App with Node.js and htmx
James Hibbard
Digital Transformation with AI: The Benefits and Challenges
Digital Transformation with AI: The Benefits and Challenges
Priyanka Prajapat
Quick Tip: Creating a Date Picker in React
Quick Tip: Creating a Date Picker in React
Dianne Pena
How to Create Interactive Animations Using React Spring
How to Create Interactive Animations Using React Spring
Yemi Ojedapo
10 Reasons to Love Google Docs
10 Reasons to Love Google Docs
Joshua KrausZain Zaidi
How to Use Magento 2 for International Ecommerce Success
How to Use Magento 2 for International Ecommerce Success
Mitul Patel
5 Exciting New JavaScript Features in 2024
5 Exciting New JavaScript Features in 2024
Olivia GibsonDarren Jones
Tools and Strategies for Efficient Web Project Management
Tools and Strategies for Efficient Web Project Management
Juliet Ofoegbu
Choosing the Best WordPress CRM Plugin for Your Business
Choosing the Best WordPress CRM Plugin for Your Business
Neve Wilkinson
ChatGPT Plugins for Marketing Success
ChatGPT Plugins for Marketing Success
Neil Jordan
Managing Static Files in Django: A Comprehensive Guide
Managing Static Files in Django: A Comprehensive Guide
Kabaki Antony
The Ultimate Guide to Choosing the Best React Website Builder
The Ultimate Guide to Choosing the Best React Website Builder
Dianne Pena
Exploring the Creative Power of CSS Filters and Blending
Exploring the Creative Power of CSS Filters and Blending
Joan Ayebola
How to Use WebSockets in Node.js to Create Real-time Apps
How to Use WebSockets in Node.js to Create Real-time Apps
Craig Buckler
Best Node.js Framework Choices for Modern App Development
Best Node.js Framework Choices for Modern App Development
Dianne Pena
SaaS Boilerplates: What They Are, And 10 of the Best
SaaS Boilerplates: What They Are, And 10 of the Best
Zain Zaidi
Understanding Cookies and Sessions in React
Understanding Cookies and Sessions in React
Blessing Ene Anyebe
Enhanced Internationalization (i18n) in Next.js 14
Enhanced Internationalization (i18n) in Next.js 14
Emmanuel Onyeyaforo
Essential React Native Performance Tips and Tricks
Essential React Native Performance Tips and Tricks
Shaik Mukthahar
How to Use Server-sent Events in Node.js
How to Use Server-sent Events in Node.js
Craig Buckler
Five Simple Ways to Boost a WooCommerce Site’s Performance
Five Simple Ways to Boost a WooCommerce Site’s Performance
Palash Ghosh
Elevate Your Online Store with Top WooCommerce Plugins
Elevate Your Online Store with Top WooCommerce Plugins
Dianne Pena
Unleash Your Website’s Potential: Top 5 SEO Tools of 2024
Unleash Your Website’s Potential: Top 5 SEO Tools of 2024
Dianne Pena
How to Build a Chat Interface using Gradio & Vultr Cloud GPU
How to Build a Chat Interface using Gradio & Vultr Cloud GPU
Vultr
Enhance Your React Apps with ShadCn Utilities and Components
Enhance Your React Apps with ShadCn Utilities and Components
David Jaja
10 Best Create React App Alternatives for Different Use Cases
10 Best Create React App Alternatives for Different Use Cases
Zain Zaidi
Control Lazy Load, Infinite Scroll and Animations in React
Control Lazy Load, Infinite Scroll and Animations in React
Blessing Ene Anyebe
Building a Research Assistant Tool with AI and JavaScript
Building a Research Assistant Tool with AI and JavaScript
Mahmud Adeleye
Understanding React useEffect
Understanding React useEffect
Dianne Pena
Web Design Trends to Watch in 2024
Web Design Trends to Watch in 2024
Juliet Ofoegbu
Building a 3D Card Flip Animation with CSS Houdini
Building a 3D Card Flip Animation with CSS Houdini
Fred Zugs
How to Use ChatGPT in an Unavailable Country
How to Use ChatGPT in an Unavailable Country
Dianne Pena
An Introduction to Node.js Multithreading
An Introduction to Node.js Multithreading
Craig Buckler
How to Boost WordPress Security and Protect Your SEO Ranking
How to Boost WordPress Security and Protect Your SEO Ranking
Jaya Iyer
Understanding How ChatGPT Maintains Context
Understanding How ChatGPT Maintains Context
Dianne Pena
Building Interactive Data Visualizations with D3.js and React
Building Interactive Data Visualizations with D3.js and React
Oluwabusayo Jacobs
JavaScript vs Python: Which One Should You Learn First?
JavaScript vs Python: Which One Should You Learn First?
Olivia GibsonDarren Jones
13 Best Books, Courses and Communities for Learning React
13 Best Books, Courses and Communities for Learning React
Zain Zaidi
5 jQuery.each() Function Examples
5 jQuery.each() Function Examples
Florian RapplJames Hibbard
Implementing User Authentication in React Apps with Appwrite
Implementing User Authentication in React Apps with Appwrite
Yemi Ojedapo
AI-Powered Search Engine With Milvus Vector Database on Vultr
AI-Powered Search Engine With Milvus Vector Database on Vultr
Vultr
Understanding Signals in Django
Understanding Signals in Django
Kabaki Antony
Why React Icons May Be the Only Icon Library You Need
Why React Icons May Be the Only Icon Library You Need
Zain Zaidi
View Transitions in Astro
View Transitions in Astro
Tamas Piros
Getting Started with Content Collections in Astro
Getting Started with Content Collections in Astro
Tamas Piros
What Does the Java Virtual Machine Do All Day?
What Does the Java Virtual Machine Do All Day?
Peter Kessler
Become a Freelance Web Developer on Fiverr: Ultimate Guide
Become a Freelance Web Developer on Fiverr: Ultimate Guide
Mayank Singh
Layouts in Astro
Layouts in Astro
Tamas Piros
.NET 8: Blazor Render Modes Explained
.NET 8: Blazor Render Modes Explained
Peter De Tender
Mastering Node CSV
Mastering Node CSV
Dianne Pena
A Beginner’s Guide to SvelteKit
A Beginner’s Guide to SvelteKit
Erik KückelheimSimon Holthausen
Brighten Up Your Astro Site with KwesForms and Rive
Brighten Up Your Astro Site with KwesForms and Rive
Paul Scanlon
Which Programming Language Should I Learn First in 2024?
Which Programming Language Should I Learn First in 2024?
Joel Falconer
Managing PHP Versions with Laravel Herd
Managing PHP Versions with Laravel Herd
Dianne Pena
Accelerating the Cloud: The Final Steps
Accelerating the Cloud: The Final Steps
Dave Neary
An Alphebetized List of MIME Types
An Alphebetized List of MIME Types
Dianne Pena
The Best PHP Frameworks for 2024
The Best PHP Frameworks for 2024
Claudio Ribeiro
11 Best WordPress Themes for Developers & Designers in 2024
11 Best WordPress Themes for Developers & Designers in 2024
SitePoint Sponsors
Top 10 Best WordPress AI Plugins of 2024
Top 10 Best WordPress AI Plugins of 2024
Dianne Pena
20+ Tools for Node.js Development in 2024
20+ Tools for Node.js Development in 2024
Dianne Pena
The Best Figma Plugins to Enhance Your Design Workflow in 2024
The Best Figma Plugins to Enhance Your Design Workflow in 2024
Dianne Pena
Harnessing the Power of Zenserp for Advanced Search Engine Parsing
Harnessing the Power of Zenserp for Advanced Search Engine Parsing
Christopher Collins
Build Your Own AI Tools in Python Using the OpenAI API
Build Your Own AI Tools in Python Using the OpenAI API
Zain Zaidi
The Best React Chart Libraries for Data Visualization in 2024
The Best React Chart Libraries for Data Visualization in 2024
Dianne Pena
7 Free AI Logo Generators to Get Started
7 Free AI Logo Generators to Get Started
Zain Zaidi
Turn Your Vue App into an Offline-ready Progressive Web App
Turn Your Vue App into an Offline-ready Progressive Web App
Imran Alam
Clean Architecture: Theming with Tailwind and CSS Variables
Clean Architecture: Theming with Tailwind and CSS Variables
Emmanuel Onyeyaforo
How to Analyze Large Text Datasets with LangChain and Python
How to Analyze Large Text Datasets with LangChain and Python
Matt Nikonorov
6 Techniques for Conditional Rendering in React, with Examples
6 Techniques for Conditional Rendering in React, with Examples
Yemi Ojedapo
Introducing STRICH: Barcode Scanning for Web Apps
Introducing STRICH: Barcode Scanning for Web Apps
Alex Suzuki
Using Nodemon and Watch in Node.js for Live Restarts
Using Nodemon and Watch in Node.js for Live Restarts
Craig Buckler
Task Automation and Debugging with AI-Powered Tools
Task Automation and Debugging with AI-Powered Tools
Timi Omoyeni
Quick Tip: Understanding React Tooltip
Quick Tip: Understanding React Tooltip
Dianne Pena
Get the freshest news and resources for developers, designers and digital creators in your inbox each week