Click here to Skip to main content
Click here to Skip to main content
Go to top

Running a Windows .NET application on Linux

, 12 Mar 2013
Rate this:
Please Sign up or sign in to vote.
Running the same compiled assembly on Windows and Linux.

Introduction

Today Mono contains the core development libraries, the development and deployment tools. Most of these are command-line tools and compiler, there is no complete replacement for Visual Studio to do Windows.Forms and ASP.NET applications natively on Linux. 

You can continue to use Visual Studio to develop your applications on Windows, the binaries produced by Visual Studio are binary compatible with Mono, so you only need to get these files to your Linux/Unix server. 

The same compiled assembly will run on Windows and Linux. You can test this by compiling it on Windows, copying the assembly to a Linux machine and running the mono applicationname.exe command there or you can create a batch file.

If you create a batch file, put a check on "Allow executing file as program" in the properties->Permissions: Execute and write the follow code inside the batch file:   

#!/bin/sh
exec mono applicationname.exe 

To run the program click twice in the file or in the command type the name of the batch follow by enter, next click Run. 

If the program is inside a folder type the follow code inside the batch file:

#!/bin/sh
exec mono "./folder name/applicationname.exe" "$@" 

Note: On Windows, the directory path separator is "\" while on Linux it is "/", it is possible to create files that contain a "\" in their names on Linux. 

For more information about portability please check this link: Mono Application Portability.

Note: MonoDevelop is an IDE primarily designed for C# and other .NET languages.

Note: Works in Windows (with .NET Framework installed, except the batch file) and Linux (with Mono installed). 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nelson Kosta Souto
Engineer
Portugal Portugal
My name is Nelson Souto, I develop software for fun and profit since 1992.

Comments and Discussions

 
GeneralMy vote of 3 PinmemberPrasad Khandekar13-Mar-13 20:08 
AnswerRe: My vote of 3 PinmemberNelson Kosta Souto13-Mar-13 23:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 12 Mar 2013
Article Copyright 2012 by Nelson Kosta Souto
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid