
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Executing C# code in Linux
The .NET centric applications are meant to windows operating system up till now, but now Microsoft has introduced a new cross-platform application called Mono which enables the execution of the application developed under the .NET platform in Linux environment by giving an impression in such a way that as if we are running Linux package rather than executing .exe file.
Mono
Mono is an open-source utility that allows the developer to execute .NET centric applications on other platforms such as Mac or Linux as it provides an installation package for Windows platform to compile and execute .NET assemblies on Windows OS without ever installing the Visual Studio IDE or .NET Framework SDK. Hence, we can build real-time, production-ready assemblies that use Windows Forms, LINQ, XML web services, ADO.NET and ASP.NET by taking advantage of existing core CLR namespaces under Mono. First, download the Mono binaries using the wget utility and execute these series of commands to configure it properly as;
wget --no-check-certificate https://raw.github.com/nathanb/iws- snippets/master/mono-install-scripts/ubuntu/install_mono-3.0.sh chmod 755 install_mono-3.0.sh ./install_mono-3.0.sh
Apart from that, install the MCS package too alternatively, to compile the .NET binary as following;
root/kali:~/ sudo apt-get install mcs
C# Code Compilation
The infrastructure of the Mono console application is almost similar to the traditional C#.NET console application. To develop the first Mono based console application (test.cs), open any code editor like VIM and type the following code.
using System; namespace test { class test{ public static void Main(string[] args) { System.Console.WriteLine("C# app Compiled on Kali Linux"); } } }
Then, open the Terminal and hit the following commands to compile the code.
root/kali:~/ mcs test.cs root/kali:~/ ls test.cs test.exe
The aforesaid command will generate an executable file like windows. Now hit the ./test.exe or mono test.exe command to run the C# binary; Here, the screenshot summarized everything we have done so far.
- Related Articles
- How can I profile C++ code running in Linux?
- How can I profile C++ code running on Linux?
- Best HTML & CSS Code Editors for Linux
- Managed code vs Unmanaged code in C#
- Executing Tests on Cookies in Postman
- Read the Source Code of Shell Commands on Linux
- 5 Best Vi/Vim-Inspired Code Editors for Linux
- Gray Code in C++
- Atom – A Hackable Text and Source Code Editor for Linux
- Self Destructing Code in C
- Executing a SQL query in SAP HANA Studio
- How to cancel an executing AsyncTask in Android?
- Writing OS Independent Code in C/C++
- Locating and executing Python modules (runpy)
- What is unmanaged code in C#?
