Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Distributions»Ubuntu»How to Install Mono on Ubuntu 18.04 & 16.04

    How to Install Mono on Ubuntu 18.04 & 16.04

    By RahulMarch 31, 20202 Mins Read

    The Mono project is sponsored by the Microsoft. It is an open source, cross platform implementation of Microsoft .NET Framework. Mono supports most the modern operating systems with 32-bit and 64-bit architecture. This tutorial will help you to install Mono on Ubuntu 18.04 & 16.04 systems.

    Advertisement

    Useful tutorial:

    • How to Install Visual Studio Code on Ubuntu

    Prerequisites

    Login to the Ubuntu system with sudo privileged account.

    Install Mono on Ubuntu

    First of all, install some required packages and import GPG key to your system.

    sudo apt install gnupg ca-certificates
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D3D831EF
    

    You need to add Apt repository provide by the official project team. Use one of the following commands to add Mono repository to your system based on Ubuntu version.

    ### Ubuntu 18.04 LTS 
    echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-stable.list
    
    ### Ubuntu 16.04 LTS 
    echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | sudo tee /etc/apt/sources.list.d/mono-stable.list
    

    Once the repository is added. Update the apt cache and install Mono packages on your Ubuntu system.

    sudo apt update
    sudo apt install mono-complete mono-devel
    

    The mono-devel package is used to compile code. The mono-complete package is used to install everything on the system.

    Check Mono Version

    Once the installation has finished on your system. Let’s check the installed Mono version using the following command.

    mono --version
    

    Output:

    Mono JIT compiler version 6.8.0.105 (tarball Tue Feb  4 21:20:20 UTC 2020)
    Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
            TLS:           __thread
            SIGSEGV:       altstack
            Notifications: epoll
            Architecture:  amd64
            Disabled:      none
            Misc:          softdebug
            Interpreter:   yes
            LLVM:          yes(610)
            Suspend:       hybrid
            GC:            sgen (concurrent by default)
    

    Run Example with Mono

    As you have installed Mono on your Ubuntu system. Create a sample c# program to run with Mono. Create a Welcome.cs file and edit in your favorite text editor.

    vim Welcome.cs
    

    Add below value to file.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    using System;
     
    public class Welcome
    {
        public static void Main(string[] args)
        {
            Console.WriteLine ("Welcome to TecAdmin.net");
        }
    }

    Save file and close it. Then compile the c# program with the c# compiler using below command.

    csc Welcome.cs
    

    Once the compilation finished successfully, it will create a exe file in the local directory with the same name as script. In this case a Welcome.exe file is generated in my local directory.

    Set the exectue permission and then run the program

    chmod +x Welcome.exe
    ./Welcome.exe
    

    You will see the output like below screenshot:

    Install Mono on Ubuntu

    All done, You have successfully installed Mono on your Ubuntu system. Next you may requried to install Visual Studio Code on Ubuntu.

    dotnet Framework Mono
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Developing a Simple Mobile App with Ionic Framework

    How to Setup DKIM (DomainKeys) with Postfix

    A Step-by-Step Guide to Installing OpenDKIM with Postfix on Ubuntu – Unleash the Power of DKIM!

    How to Install Dotnet Core on macOS

    How to Install .NET Core on macOS

    View 1 Comment

    1 Comment

    1. ThePageinc on July 7, 2021 12:56 pm

      Straight to the point, no messing around, this man know what tutorials are all about!

      Oh! ..and it worked 1st attempt!

      nice job!

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Configure Postfix to Use Gmail SMTP on Ubuntu & Debian
    • PHP Arrays: A Beginner’s Guide
    • Deploying Flask Application on Ubuntu (Apache+WSGI)
    • OpenSSL: Working with SSL Certificates, Private Keys and CSRs
    • How to Create and Read List in Python
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.