Difference between revisions of "Mono"

From ArchWiki
Jump to: navigation, search
m (Added monodevelop-stable as package option (does not rely on gnome dependencies (specifically gnome-sharp)).)
 
(23 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[[Category:Development]]
+
[[Category:Framework]]
Mono is an open source, cross-platform, implementation of C# and the CLR that is binary compatible with Microsoft.NET.
+
[[ja:Mono]]
 +
From [[Wikipedia:Mono (software)|Wikipedia]]:
  
==Installation==
+
:''Mono is a [...] project to create a [[Wikipedia:.NET Framework|.NET Framework]]-compatible set of tools including, among others, a [[Wikipedia:C Sharp (programming language)|C#]] compiler and a [[Wikipedia:Common Language Runtime|Common Language Runtime]].''
Mono can be [[pacman|installed]] with the package {{Pkg|mono}}, available in the [[Official Repositories]].
 
  
If you need VisualBasic.Net support you have to [[pacman|install]] the VisualBasic.Net interpreter with the package {{Pkg|mono-basic}}, available in the [[Official Repositories]].
+
== Installation ==
==Registering Mono Applications with the Kernel==
 
  
You can execute binaries by calling {{ic|mono}} manually
+
[[Install]] the {{Pkg|mono}} package.
  
mono programsname.exe
+
If you need VisualBasic.Net support you have to [[install]] the VisualBasic.Net interpreter with the package {{AUR|mono-basic}}.
  
It is also possible to tell the kernel to use {{ic|mono}} as an interpreter for all Mono binaries. To do it, just load {{ic|mono}} [[kernel module]] and it will automatically be setup for you.
+
MonoDevelop calls [[xterm]] when you run your project. You might install it, when you're writing a console application.
  
Then try this:
+
== Running Mono applications ==
  
chmod 755 exefile.exe
+
You can execute Mono binaries by calling {{ic|mono}} manually:
./exefile.exe
 
  
==Testing Mono==
+
$ mono programsname.exe
Make a new file; test.cs
+
 
{{bc|
+
You can also execute Mono binaries directly, just like native binaries:
 +
 
 +
$ chmod 755 exefile.exe
 +
$ ./exefile.exe
 +
 
 +
== Testing Mono ==
 +
 
 +
Make a new file:
 +
{{hc|test.cs|
 
using System;
 
using System;
  
Line 37: Line 43:
 
}}
 
}}
  
==Development==
+
== Development ==
Starting to develop in Mono/C# is very easy. Just [[pacman|install]] the [http://monodevelop.com/ MonoDevelop IDE] and debugger support with packages {{Pkg|monodevelop}}, {{Pkg|monodevelop-debugger-gdb}}, available in the [[Official Repositories]].  
+
 
 +
Starting to develop in Mono/C# is very easy. Just [[install]] the [http://monodevelop.com/ MonoDevelop IDE] with package {{AUR|monodevelop-stable}} or {{AUR|monodevelop-git}}.
 +
Alternatively, you can install the {{AUR|rider}} IDE.
  
 
If you want the API documentation browser and some testing and development tools you have to install {{Pkg|mono-tools}}.
 
If you want the API documentation browser and some testing and development tools you have to install {{Pkg|mono-tools}}.
 +
 +
== Troubleshooting ==
 +
 +
=== I get an error "cannot execute "path/to/your/binary" file name has not been set." ===
 +
You might install [[xterm]], since MonoDevelop starts [[xterm]] when you press on run. This might be a
 +
possible dependency.
 +
 +
=== I get an error when I try to run Mono binaries directly: "cannot execute binary file" ===
 +
 +
The [[Wikipedia:Binfmt_misc|binfmt_misc]] handler for Mono has not yet been set up, as explained in detail on the [http://www.mono-project.com/Guide:Running_Mono_Applications#Registering_.exe_as_non-native_binaries_.28Linux_only.29 Mono Project website].
 +
 +
To fix this, [[daemon|restart]] the {{ic|systemd-binfmt}} service.
 +
 +
=== I get an TLS handshake (or similar certificate based) error ===
 +
 +
Try {{ic|mozroots --import --ask-remove}} which should update monos certificates. {{ic|mozroots}} is part of the mono package.
 +
 +
=== I get an error when building fsharp: "System.TypeInitializationException: The type initializer for 'System.Console' threw an exception" ===
 +
 +
There is a recent bug in mcs that is used to build fsharp. A workaround is to use {{ic|1=export TERM=xterm}}, as detailed here [https://github.com/mono/mono/issues/6752]
 +
  
 
== See also ==
 
== See also ==
*[http://www.mono-project.com Official Mono website]
+
 
*[http://mono-project.com/Monkeyguide The Mono Handbook]
+
* [http://www.mono-project.com Official Mono website]
*[http://go-mono.org/docs The API reference of Mono]
+
* [http://mono-project.com/Monkeyguide The Mono Handbook]
*[http://www.ecma-international.org/publications/standards/ECMA-334.HTM ECMA-334: C# Language Specification]
+
* [http://go-mono.org/docs The API reference of Mono]
*[http://www.ecma-international.org/publications/standards/ECMA-335.HTM ECMA-335: Common Language Infrastructure (CLI)]
+
* [http://www.ecma-international.org/publications/standards/ECMA-334.HTM ECMA-334: C# Language Specification]
 +
* [http://www.ecma-international.org/publications/standards/ECMA-335.HTM ECMA-335: Common Language Infrastructure (CLI)]
 +
* [http://www.mono-project.com/Guide:Running_Mono_Applications Instructions for running Mono applications]

Latest revision as of 03:50, 18 April 2018

From Wikipedia:

Mono is a [...] project to create a .NET Framework-compatible set of tools including, among others, a C# compiler and a Common Language Runtime.

Installation

Install the mono package.

If you need VisualBasic.Net support you have to install the VisualBasic.Net interpreter with the package mono-basicAUR.

MonoDevelop calls xterm when you run your project. You might install it, when you're writing a console application.

Running Mono applications

You can execute Mono binaries by calling mono manually:

$ mono programsname.exe

You can also execute Mono binaries directly, just like native binaries:

$ chmod 755 exefile.exe
$ ./exefile.exe

Testing Mono

Make a new file:

test.cs
using System;

public class Test {
 public static void Main(string[] args) {
  Console.WriteLine("Hello World!");
 }
}

Then run:

$ mcs test.cs
$ mono test.exe
Hello world!

Development

Starting to develop in Mono/C# is very easy. Just install the MonoDevelop IDE with package monodevelop-stableAUR or monodevelop-gitAUR. Alternatively, you can install the riderAUR IDE.

If you want the API documentation browser and some testing and development tools you have to install mono-tools.

Troubleshooting

I get an error "cannot execute "path/to/your/binary" file name has not been set."

You might install xterm, since MonoDevelop starts xterm when you press on run. This might be a possible dependency.

I get an error when I try to run Mono binaries directly: "cannot execute binary file"

The binfmt_misc handler for Mono has not yet been set up, as explained in detail on the Mono Project website.

To fix this, restart the systemd-binfmt service.

I get an TLS handshake (or similar certificate based) error

Try mozroots --import --ask-remove which should update monos certificates. mozroots is part of the mono package.

I get an error when building fsharp: "System.TypeInitializationException: The type initializer for 'System.Console' threw an exception"

There is a recent bug in mcs that is used to build fsharp. A workaround is to use export TERM=xterm, as detailed here [1]


See also