Running .C# code into Ubuntu OS

With MS coming up with ASP.Net vNext which has capability to run across platforms using Mono. But here are the steps you can perform on Ubuntu OS to run .Net code with existing framework
# If you're on Windows OS then the prerequisite is to install Oracle VirtualBox and Ubuntu .ISO image
# At Ubuntu terminal, download and install following packages via terminal:
  1. sudo apt-add-repository ppa:directhex/ppa  
  2. sudo apt-get update  
  3. sudo apt-get install monodevelop  
# Incase you face any issue try running below command
  1. sudo apt-get -f install  
# Now, install mcs utility which can compile your C# into exe file
  1. sudo apt-get install mcs  
# ALL Set now!
# Create MonoTest.cs file e.g.,
  1. using System;  
  2.   
  3. namespace MonoTest  
  4. {  
  5.    class Program  
  6.    {  
  7.      static void Main(string[] args)  
  8.       {  
  9.           Console.WriteLine("Hai to Mono");  
  10.           Console.Read();  
  11.       }  
  12.    }  
  13. }  
# Compile MonoTest.CS file
  1. mcs MonoTest.CS  
# Run MonoTest.exe using mono
  1. mono MonoTest.exe  
Ebook Download
View all
Learn
View all