Sinisterly
Tutorial [sunjester tuts] Using C# (.NET code/apps) on Linux - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework)
+--- Thread: Tutorial [sunjester tuts] Using C# (.NET code/apps) on Linux (/Thread-Tutorial-sunjester-tuts-Using-C-NET-code-apps-on-Linux)



[sunjester tuts] Using C# (.NET code/apps) on Linux - sunjester - 03-11-2019

Introduction
All of my tutorials are written, tested, and meant to be used on Linux. I am using Ubuntu xenial (currently 16.04). You can use any debian distro and follow any of my tutorials. I will not pander to the Windows kiddies, don't ask.
 
Directions
First, let's check what version you have, you can use the lsb_release command.
Code:
lsb_release -a
 
18.04
Code:
sudo apt install gnupg ca-certificates sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update
 
16.04
Code:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF sudo apt install apt-transport-https ca-certificates echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update 
 
14.04
Code:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF sudo apt install apt-transport-https ca-certificates echo "deb https://download.mono-project.com/repo/ubuntu stable-trusty main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update
 
Next, install Mono
Code:
sudo apt install mono-devel
Now we can compile and then run the C# code below, that i've saved in a file named hello.cs
Code:
using System; public class HelloWorld {    static public void Main ()    {        Console.WriteLine ("Hello World");    } }
using the csc to compile
csc hello.cs
 
and using mono to run the .net executable
mono hello.exe
 
WinForms
You can compile the winforms applications using the following argument
Code:
-r:System.Windows.Forms.dll
Gtk# Forms
Code:
-pkg:gtk-sharp-2.0



RE: [sunjester tuts] Using C# (.NET code/apps) on Linux - inquis1t0r - 03-13-2019

Well mono is kind of obsolete, when .NET Core is out with UI libraries going to be release really soon + here is AvaloniaUI for impatient.


RE: [sunjester tuts] Using C# (.NET code/apps) on Linux - phyrrus9 - 03-22-2019

(03-13-2019, 11:01 AM)inquis1t0r Wrote: Well mono is kind of obsolete, when .NET Core is out with UI libraries going to be release really soon + here is AvaloniaUI for impatient.

.net core has been out for quite some time. Mono is simply the runtime. Unless you're not using any dependencies, then you'll need it.


RE: [sunjester tuts] Using C# (.NET code/apps) on Linux - sunjester - 03-22-2019

mono is an IDE for building .net applications on linux, it's not obsolete.


RE: [sunjester tuts] Using C# (.NET code/apps) on Linux - darkninja1980 - 03-24-2019

(03-11-2019, 09:55 PM)sunjester Wrote: Introduction
All of my tutorials are written, tested, and meant to be used on Linux. I am using Ubuntu xenial (currently 16.04). You can use any debian distro and follow any of my tutorials. I will not pander to the Windows kiddies, don't ask.
 
Directions
First, let's check what version you have, you can use the lsb_release command.
Code:
lsb_release -a
 
18.04
Code:
sudo apt install gnupg ca-certificates sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update
 
16.04
Code:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF sudo apt install apt-transport-https ca-certificates echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update 
 
14.04
Code:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF sudo apt install apt-transport-https ca-certificates echo "deb https://download.mono-project.com/repo/ubuntu stable-trusty main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update
 
Next, install Mono
Code:
sudo apt install mono-devel
Now we can compile and then run the C# code below, that i've saved in a file named hello.cs
Code:
using System; public class HelloWorld {    static public void Main ()    {        Console.WriteLine ("Hello World");    } }
using the csc to compile
csc hello.cs
 
and using mono to run the .net executable
mono hello.exe
 
WinForms
You can compile the winforms applications using the following argument
Code:
-r:System.Windows.Forms.dll
Gtk# Forms
Code:
-pkg:gtk-sharp-2.0

nice little tutorial. Smile


RE: [sunjester tuts] Using C# (.NET code/apps) on Linux - bumbuls6 - 11-26-2023

The only thing VB has going for it is the basic syntax if you grew on it so it has a sorta nostalgic value ("muh goto").