
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- How can I profile C++ code running in Linux?
- How can I profile C++ code running on Linux?
- Managed code vs Unmanaged code in C#
- Executing Tests on Cookies in Postman
- Gray Code in C++
- Locating and executing Python modules (runpy)
- File globbing in Linux in C++
- Self Destructing Code in C
- C program for pipe in Linux
- Executing a SQL query in SAP HANA Studio
- How to cancel an executing AsyncTask in Android?
- Writing OS Independent Code in C/C++
- 8085 Executing the program and checking result
- MongoDB indexes not working when executing $elemMatch?
- What is unmanaged code in C#?