In the next article we are going to take a look at Mono. This is a platform to develop and run cross-platform applications. It is a free and open source implementation of the .NET Framework from Microsoft.
Monkey is the name of this open source project started by Ximian and backed by Microsoft. It is currently being promoted by Novell to create a group of free tools, based on GNU / Linux and compatible with . NET, as specified by ECMA.
Sponsored by Microsoft, Mono is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C # and the Common Language Runtime. Behind the project there is also a collaborative and active community that is helping to position this as an option for the development of multiplatform applications.
Install Mono on Ubuntu 18.04
The easiest and recommended way to install Mono on Ubuntu 18.04 is install it from repositories. This is a relatively straightforward process. We'll just have to start by installing the prerequisites. We will do this by opening a terminal (Ctrl + Alt + T) and typing in it the commands:
sudo apt update; sudo apt install dirmngr gnupg apt-transport-https ca-certificates
We continue importing from the same terminal the GPG key of the repository using the following command:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
The output should look something like the previous screenshot. At this point, we can add the required repository to the list of sources of our system by executing the following command:
sudo sh -c 'echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" > /etc/apt/sources.list.d/mono-official-stable.list'
Once the apt repository is enabled, we will start updating the list of available software from the repository:
sudo apt update
After the update we can now launch the installation:
sudo apt install mono-complete
The package monkey-complete we will install it to install everything. From development tools to all libraries. This should cover most cases of errors of the type 'assembly not found'. In addition to this package, these others can be selected for installation:
- The package mono-devel, which must be installed to compile code.
- mono-dbg must be installed to get debug symbols for framework libraries.
- The package referenceassemblies-pcl we will install it for PCL compilation support. This should solve most of the error cases'Framework not installed: .NETPortable'during compilation of the software.
- ca-certificates-mono It must be installed to obtain SSL certificates for HTTPS connections. We will install this package if we have trouble making HTTPS connections.
- The package monkey-xsp4 It must be installed to run ASP.NET applications.
Verify the installation
After a successful installation, we can verify installation typing the following command which will print the installed version:
mono --version
As I write these lines, the latest stable version of Mono is 6.6.0. They can consult all its characteristics in the release note, published on the project website.
This is all you need to successfully install Mono on Ubuntu 18.04. But if anyone has doubts about the installation, they can consult the information offered in the Downloads page From this project.
Testing Mono
To verify that everything is configured correctly, we are going to create a basic "Hello World puedo cambiarlo”That will print the classic message. To do so, we will open our favorite text editor and create a file called hello.cs. Inside we will place the following content:
using System; public class HolaMundo { public static void Main(string[] args) { Console.WriteLine ("Hola Ubunlog!"); } }
Pasted the content, we save the file and go back to the terminal. The next step is use the csc compiler to compile the program. We will achieve this using the following command, from the same folder in which we have saved the previous file:
csc hola.cs
The above command will create an executable called hello.exe. We are going to execute this new file with the command:
mono hola.exe
In case we are interested in being able to run the program by typing only the file name, it will have to be made executable with the command:
chmod +x hola.exe
Now we can run the hello.exe file by just writing its name:
./hola.exe
For more information about how to use Mono, you can consult the section dedicated to this topic in the page on GitHub of the project. Can also be found information about Mono in its Official documentation. These documents cover specific topics on how to configure it, or information about Mono's internals, such as the runtime, the garbage collector, or various specific tools.
I would like you to help me, after installing MONO and creating a solution, when reviewing the references, it tells me this in almost all of it "Cannot find .NET Framework 4.7 platform assembly". The solution can be created but is not executed, since it gives an error. Can you help me?