HomeLinuxThe best way to Set up Mono .NET Framework in RHEL-based Linux

The best way to Set up Mono .NET Framework in RHEL-based Linux


Mono is a free, open-source, and cross-platform implementation of Microsoft’s .NET framework, which runs on Linux, macOS, BSD, and Home windows and helps varied CPU architectures akin to x86, ARM, PowerPC, and extra. Mono permits software program builders to simply create cross-platform functions utilizing C# language.

The Mono undertaking is sponsored by Microsoft and is a part of the .NET basis, which is comprised of the C# compiler, the mono runtime, the bottom class library, and the mono class library.

On this information, we are going to present learn how to set up Mono (Open Supply .NET Framework) in RHEL-based distributions akin to CentOS, Rocky Linux, AlmaLinux, and Fedora Linux. It additionally exhibits learn how to compile and run mono packages from the command line.

Putting in Mono in RHEL-based Distributions

To put in Mono, first, arrange the package deal repository in your system, then set up the mono package deal by working the next instructions. Bear in mind to run the suitable instructions on your working system model.

For every model part, the primary command imports the repository key, the curl command units up the repository configuration file, and the ultimate dnf command installs the mono package deal.

On CentOS/RHEL/Rocky & AlmaLinux 8

# rpmkeys --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
# su -c 'curl https://obtain.mono-project.com/repo/centos8-stable.repo | tee /and so on/yum.repos.d/mono-centos8-stable.repo'
# dnf set up mono-devel

On CentOS/RHEL 7

# rpmkeys --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
# su -c 'curl https://obtain.mono-project.com/repo/centos7-stable.repo | tee /and so on/yum.repos.d/mono-centos7-stable.repo'
# yum set up mono-devel

On CentOS/RHEL 6

# rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
# su -c 'curl https://obtain.mono-project.com/repo/centos6-stable.repo | tee /and so on/yum.repos.d/mono-centos6-stable.repo'
# yum set up mono-devel

On Fedora 29 and Later

# rpm --import "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
# su -c 'curl https://obtain.mono-project.com/repo/centos8-stable.repo | tee /and so on/yum.repos.d/mono-centos8-stable.repo'
# dnf replace
# dnf set up mono-devel

The next are additional mono packages you too can set up:

  • mono-complete – accommodates the whole lot required for working with Mono functions.
  • mono-dbg – provides debugging symbols for framework libraries.
  • referenceassemblies-pcl – provides PCL compilation assist, and.
  • xsp – an internet server required for working ASP.NET functions.

For instance, you’ll be able to set up the mono-complete package deal like so:

# yum set up mono-complete
OR
# dnf set up mono-complete

After efficiently putting in the Mono package deal in your system, you want to confirm the set up. A easy step is to test the model of the mono package deal put in, as follows:

# mono -V
OR
# mono --version

The best way to Compile and Run Mono Applications in Linux Terminal

The subsequent step is to make sure that the Mono elements are correctly arrange. You’ll be able to take a look at this utilizing a small hiya world program. Copy the next code and paste it right into a file known as hiya.cs.

utilizing System;
public class HelloWorld
{
    public static void Foremost(string[] args)
    {
        Console.WriteLine ("Whats up Mono World – That is TecMint.com");
    }
}

Now compile the hiya.cs program utilizing the C# compiler (csc) by working the next command. It would generate a hiya.exe executable file inside the present listing.

$ csc hiya.cs
Compile Program in Linux
Compile Program in Linux

Subsequent, run the hiya.exe executable file utilizing the mono command. It ought to show the string: Whats up Mono World – That is TecMint.com as proven within the screenshot that follows.

$ mono hiya.exe
Run Windows .exe Program in Linux
Run Home windows .exe Program in Linux

Let’s have a look at one other easy instance code, which can create a System.Home windows.Varieties desktop software. Copy and paste it right into a hello2.cs file.

utilizing System;
utilizing System.Home windows.Varieties;

public class HelloWorld : Kind
{
    static public void Foremost ()
    {
        Software.Run (new HelloWorld ());
    }

    public HelloWorld ()
    {
        Textual content = "Whats up Mono World – That is TecMint.com";
    }
}

Subsequent, compile this system like earlier than utilizing the csc command as follows. It would additionally generate an executable file known as hello2.exe inside the working listing.

$ csc hello2.cs

Now run the hello2.exe executable, which can output a small GUI (graphical consumer interface) desktop software as proven within the following screenshot.

$ mono hello2.exe
Create Desktop Application in Linux
Create Desktop Software in Linux

You’ll be able to view all mono command choices by working the next command:

$ mono -h

That’s all for now! The Mono undertaking is supported by an lively and enthusiastic contributing group. If you’re within the undertaking, you’ll be able to contribute by submitting a bug report, including new code or chatting with the builders, or far more.

For extra details about the Mono undertaking, take a look at the undertaking’s official web site: https://www.mono-project.com/

If You Admire What We Do Right here On TecMint, You Ought to Think about:

TecMint is the quickest rising and most trusted group website for any form of Linux Articles, Guides and Books on the internet. Thousands and thousands of individuals go to TecMint! to go looking or browse the hundreds of revealed articles obtainable FREELY to all.

When you like what you’re studying, please contemplate shopping for us a espresso ( or 2 ) as a token of appreciation.

Support Us

We’re grateful on your by no means ending assist.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments