- Mono is a software platform designed to allow developers to easily create cross platform applications. It is an open source implementation of Microsoft's.NET Framework based on the ECMA standards for C# and the Common Language Runtime.
- The 'Visual Studio is currently running on Mono 5.2.0.104' message tells you what the Visual Studio for Mac is running on. It does not indicate what your project will be run with.
It is possible, with quite a bit of hacking and some toolchain fun to compile a.NET app statically targeted for the Mac OS platform, no need to deploy mono with it. Check out this website talking about how Mono is being used statically in some iPhone apps. Apple TV (running on the Mono runtime) Apple Watch (running on the Mono runtime) The advantage of using Xamarin on mobile platforms is that you can use the Xamarin Essentials library to interact with mobile platform APIs easily from.NET.
Mono is a software platform designed to allow developers to easilycreate cross platform applications. It is an open sourceimplementation of Microsoft's .NET Framework based on the ECMAstandards for C# and the Common Language Runtime.
The Mono project is part of the .NET Foundation
Build Status
OS | Architecture | Status |
---|---|---|
Debian 9 | amd64 | |
Debian 9 | i386 | |
Debian 9 | armel | |
Debian 9 | armhf | |
Debian 9 | arm64 | |
OS X | amd64 | |
OS X | i386 | |
Windows | amd64 | |
Windows | i386 | |
CentOS | s390x (cs) | |
Debian 9 | ppc64el (cs) | |
AIX | ppc64 (cs) |
(cs) = community supported architecture
Building the Software
Please see our guides for building Mono onMac OS X,Linux andWindows.
Note that building from Git assumes that you already have Mono installed,so please download and install the latest Mono releasebefore trying to build from Git. This is required because the Mono buildrelies on a working Mono C# compiler to compile itself(also known as bootstrapping).
If you don't have a working Mono installation
If you don't have a working Mono installation, you can try a slightlymore risky approach: getting the latest version of the 'monolite' distribution,which contains just enough to run the 'mcs' compiler. You do this with:
This will download and place the files appropriately so that you can thenjust run:
The build will then use the files downloaded by
make get-monolite-latest
.Mono Runtime Terminal
Testing and Installation
You can run the mono and mcs test suites with the command:
make check
.Expect to find a few test suite failures. As a sanity check, youcan compare the failures you got with https://jenkins.mono-project.com/.
You can now install mono with:
make install
You can verify your installation by using the mono-test-installscript, it can diagnose some common problems with Mono's install.Failure to follow these steps may result in a broken installation.
Once you have installed the software, you can run a few programs:
mono program.exe
runtime enginemcs program.cs
C# compilermonodis program.exe
CIL Disassembler
See the man pages for mono(1), mcs(1) and monodis(1) for further details.
acceptance-tests/
- Optional third party test suites used to validate Mono against a wider range of test cases.data/
- Configuration files installed as part of the Mono runtime.docs/
- Technical documents about the Mono runtime.external/
- Git submodules for external libraries (Newtonsoft.Json, ikvm, etc).ikvm-native/
- Glue code for ikvm.libgc/
- The (deprecated) Boehm GC implementation.llvm/
- Utility Makefiles for integrating the Mono LLVM fork.m4/
- General utility Makefiles.man/
- Manual pages for the various Mono commands and programs.mcs/
- The class libraries, compiler and toolsclass/
- The class libraries (like System.*, Microsoft.Build, etc.)mcs/
- The Mono C# compiler written in C#tools/
- Tools like gacutil, ikdasm, mdoc, etc.
mono/
- The core of the Mono Runtime.arch/
- Architecture specific portions.benchmark/
- A collection of benchmarks.btls/
- Build files for the BTLS library which incorporates BoringSSL.cil/
- Common Intermediate Representation, XMLdefinition of the CIL bytecodes.dis/
- CIL executable Disassembler.eglib/
- Independent implementation of the glib API.metadata/
- The object system and metadata reader.mini/
- The Just in Time Compiler.profiler/
- The profiler implementation.sgen/
- The SGen Garbage Collector implementation.tests/
- The main runtime tests.unit-tests/
- Additional runtime unit tests.utils/
- Utility functions used across the runtime codebase.
msvc/
- Logic for the MSVC / Visual Studio based runtime and BCL build system.The latter is experimental at the moment.packaging/
- Packaging logic for the OS X and Windows Mono packages.po/
- Translation files.runtime/
- A directory that contains the Makefiles that link themono/ and mcs/ build systems.samples/
- Some simple sample programs on uses of the Monoruntime as an embedded library.scripts/
- Scripts used to invoke Mono and the corresponding program.sdks/
- A new way of embedding Mono into Xamarin.iOS, Xamarin.Android and other products.support/
- Various support libraries.tools/
- A collection of tools, mostly used during Mono development.
Before submitting changes to Mono, please review the contributionguidelines.Please pay particular attention to the ImportantRulessection.
To submit bug reports, please open an issue on the mono GitHub repo.
Please use the search facility to ensure the same bug hasn't alreadybeen submitted and follow ourguidelineson how to make a good bug report.
The following are the configuration options that someone building Monomight want to use:
--with-sgen=yes,no
- Generational GC support: Used to enable ordisable the compilation of a Mono runtime with the SGen garbagecollector.- On platforms that support it, after building Mono, you will haveboth a
mono-boehm
binary and amono-sgen
binary.mono-boehm
uses Boehm,whilemono-sgen
uses the Simple Generational GC.
- On platforms that support it, after building Mono, you will haveboth a
--with-libgc=[included, none]
- Selects the default Boehmgarbage collector engine to use.- included: (slightly modified Boehm GC) This is the defaultvalue for the Boehm GC, and it's the most feature complete, it willallow Mono to use typed allocations and support the debugger.
- none:Disables the inclusion of a Boehm garbage collector.
- This defaults to
included
.
--enable-cooperative-suspend
- If you pass this flag the Mono runtime is configured to only usethe cooperative mode of the garbage collector. If you do not passthis flag, then you can control at runtime the use of thecooperative GC mode by setting the
MONO_ENABLE_COOP_SUSPEND
flag.
- If you pass this flag the Mono runtime is configured to only usethe cooperative mode of the garbage collector. If you do not passthis flag, then you can control at runtime the use of thecooperative GC mode by setting the
--with-tls=__thread,pthread
- Controls how Mono should access thread local storage,pthread forces Mono to use the pthread APIs, while__thread uses compiler-optimized access to it.
- Although __thread is faster, it requires support fromthe compiler, kernel and libc. Old Linux systems donot support with __thread.
- This value is typically pre-configured and there is noneed to set it, unless you are trying to debug a problem.
--with-sigaltstack=yes,no
- Experimental: Use at your own risk, it is known tocause problems with garbage collection and is hard toreproduce those bugs.
- This controls whether Mono will install a specialsignal handler to handle stack overflows. If set to
yes
, it will turn stack overflows into theStackOverflowException. Otherwise when a stackoverflow happens, your program will receive asegmentation fault. - The configure script will try to detect if youroperating system supports this. Some older Linuxsystems do not support this feature, or you might wantto override the auto-detection.
--with-static_mono=yes,no
- This controls whether
mono
should link against astatic library (libmono.a) or a shared library(libmono.so). - This defaults to
yes
, and will improve the performanceof themono
program. - This only affects the `mono' binary, the sharedlibrary libmono.so will always be produced fordevelopers that want to embed the runtime in theirapplication.
--with-xen-opt=yes,no
- Optimize code for Xen virtualization.- It makes Mono generate code which might be slightlyslower on average systems, but the resulting executable will runfaster under the Xen virtualization system.
- This defaults to
yes
.
--with-large-heap=yes,no
- Enable support for GC heaps larger than 3GB.- This defaults to
no
.
- This defaults to
--enable-small-config=yes,no
- Enable some tweaks to reduce memory usageand disk footprint at the expense of some capabilities.- Typically this means that the number of threads that can be createdis limited (256), that the maximum heap size is also reduced (256 MB)and other such limitations that still make mono useful, but more suitableto embedded devices (like mobile phones).
- This defaults to
no
.
--with-ikvm-native=yes,no
- Controls whether the IKVM JNI interface library isbuilt or not.- This is used if you are planning onusing the IKVM Java Virtual machine with Mono.
- This defaults to
yes
.
--with-profile4=yes,no
- Whether you want to build the 4.x profile librariesand runtime.- This defaults to
yes
.
- This defaults to
--with-libgdiplus=installed,sibling,<path>
- Configure where Monosearches for libgdiplus when running System.Drawing tests.- It defaults to
installed
, which means that thelibrary is available to Mono through the regularsystem setup. sibling
can be used to specify that a libgdiplusthat resides as a sibling of this directory (mono)should be used.
- Or you can specify a path to a libgdiplus.
--enable-minimal=LIST
- Use this feature to specify optional runtimecomponents that you might not want to include. Thisis only useful for developers embedding Mono thatrequire a subset of Mono functionality.
- The list is a comma-separated list of components thatshould be removed, these are:
aot
:Disables support for the Ahead of Time compilation.attach
:Support for the Mono.Management assembly and theVMAttach API (allowing code to be injected intoa target VM)com
:Disables COM support.debug
:Drop debugging support.decimal
:Disables support for System.Decimal.full_messages
:By default Mono comes with a full tableof messages for error codes. This featureturns off uncommon error messages and reducesthe runtime size.generics
:Generics support. Disabling this will notallow Mono to run any 2.0 libraries orcode that contains generics.jit
:Removes the JIT engine from the build, this reducesthe executable size, and requires that all codeexecuted by the virtual machine be compiled withFull AOT before execution.large_code
:Disables support for large assemblies.logging
:Disables support for debug logging.pinvoke
:Support for Platform Invocation services,disabling this will drop support for anylibraries using DllImport.portability
:Removes support for MONO_IOMAP, the environmentvariables for simplifying porting applications thatare case-insensitive and that mix the Unix and Windows path separators.profiler
:Disables support for the default profiler.reflection_emit
:Drop System.Reflection.Emit supportreflection_emit_save
:Drop support for saving dynamically createdassemblies (AssemblyBuilderAccess.Save) inSystem.Reflection.Emit.shadow_copy
:Disables support for AppDomain's shadow copies(you can disable this if you do not plan onusing appdomains).simd
:Disables support for the Mono.SIMD intrinsicslibrary.ssa
:Disables compilation for the SSA optimizationframework, and the various SSA-based optimizations.
--enable-llvm
--enable-loadedllvm
- This enables the use of LLVM as a code generation enginefor Mono. The LLVM code generator and optimizer will beused instead of Mono's built-in code generator for bothJust in Time and Ahead of Time compilations.
- See https://www.mono-project.com/docs/advanced/mono-llvm/ for thefull details and up-to-date information on this feature.
- You will need to have an LLVM built that Mono can linkagainst.
- The
--enable-loadedllvm
variant will make the LLVM backendinto a runtime-loadable module instead of linking it directlyinto the main mono binary.
--enable-big-arrays
- Enable use of arrays with indexes largerthan Int32.MaxValue.- By default Mono has the same limitation as .NET onWin32 and Win64 and limits array indexes to 32-bitvalues (even on 64-bit systems).
- In certain scenarios where large arrays are required,you can pass this flag and Mono will be built tosupport 64-bit arrays.
- This is not the default as it breaks the C embeddingABI that we have exposed through the Mono developmentcycle.
--enable-parallel-mark
- Use this option to enable the garbage collector to usemultiple CPUs to do its work. This helps performanceon multi-CPU machines as the work is divided across CPUS.
- This option is not currently the default on OSXas it runs into issues there.
- This option only applies to the Boehm GC.
--enable-dtrace
- On Solaris and MacOS X builds a version of the Monoruntime that contains DTrace probes and canparticipate in the system profiling using DTrace.
--disable-dev-random
- Mono uses /dev/random to obtain good random data forany source that requires random numbers. If yoursystem does not support this, you might want todisable it.
- There are a number of runtime options to control thisalso, see the man page.
--with-csc=roslyn,mcs,default
- Use this option to configure which C# compiler to use. By defaultthe configure script will pick Roslyn, except on platforms whereRoslyn does not work (Big Endian systems) where it will pick mcs.If you specify 'mcs', then Mono's C# compiler will be used. Thisalso allows for a complete bootstrap of Mono's core compiler andcore libraries from source.
If you specify 'roslyn', then Roslyn's C# compiler will be used.This currently uses Roslyn binaries.
--enable-nacl
- This configures the Mono compiler to generate codesuitable to be used by Google's Native Client:https://code.google.com/p/nativeclient/
- Currently this is used with Mono's AOT engine asNative Client does not support JIT engines yet.
--enable-wasm
- Use this option to configure mono to run on WebAssembly. It willset both host and target to the WebAssembly triplet. This overridesthe values passed to
--host
or--target
and ignored what config.sub guesses.This is a workaround to enable usage of old automake versions that don'trecognize the wasm triplet.
![Mono runtime for mac catalina Mono runtime for mac catalina](/uploads/1/2/5/7/125750289/622556152.jpg)
Mono references several external git submodules, for examplea fork of Microsoft's reference source code that has been alteredto be suitable for use with the Mono runtime.
This section describes how to use it.
An initial clone should be done recursively so all submodules will also becloned in a single pass:
Once cloned, submodules can be updated to pull down the latest changes.This can also be done after an initial non-recursive clone:
To pull external changes into a submodule:
By default, submodules are detached because they point to a specific commit.Use
git checkout
to move back to a branch before making changes:To switch the repo of a submodule (this should not be a common or normal thingto do at all), first edit
.gitmodules
to point to the new location, then:The desired output diff is a change in
.gitmodules
to reflect thechange in the remote URL, and a change in / where you seethe desired change in the commit hash.See the LICENSE file for licensing information, and the PATENTS.TXTfile for information about Microsoft's patent grant.
The use of trademarks and logos for Mono can be found here.
Mono now ships with a solution file that can be used to build theassemblies from an IDE. Either by opening the topmost
net_4_x.sln
file, or to by loading one of the individual csproj
files located ineach directory.Download Mono Runtime For Mac
These are maintained by extracting the configuration information fromour Makefiles, which as of May 2016 remain the canonical location forconfiguration information.
When changes are made to the Makefiles, a user would need to run thefollowing command to re-generate the solution files at the top level:
Blazor traditionally runs on .NET Core for Server-side Blazor and runs the Mono runtime on WebAssembly inside thebrowser for Client-side Blazor. For desktop and mobile applications, this is cumbersome, as it requires a bundled webserver and retains the disadvantages of SSB or CSB respectively.
Steve Sanderson from Microsoft first escaped the server- / client-side jail and released a.NET Core sample that leverages nativeWebViews on Windows / Linux / macOS to show a window on these respective operating systems.Steve made ablog postdescribing his efforts; an excellent introduction to what this is.
Building on these foundations, I have created a BlazorWebView 'Control' that is easily embedded in (Native) UI frameworkson the following platforms:
- Xamarin Android (running on the Mono runtime)
- Xamarin iOS (running on the Mono runtime)
- Xamarin Mac (running on the Mono runtime)
- WPF (running on the .NET Core runtime)
I'm considering adding these platforms in the future:
- GTK Linux (running on the Mono runtime or .NET Core)
- GTK Mac (running on .NET Core)
- Windows Forms (running on the .NET Core runtime)
- Apple TV (running on the Mono runtime)
- Apple Watch (running on the Mono runtime)
The advantage of using Xamarin on mobile platforms is that you can use theXamarin Essentials library to interact with mobile platformAPIs easily from .NET.
Edgium Status
Because of the Coronavirus, the latest Edge SDK does not work with the Stable or Beta (81) builds of edge, as the code necessary to support the SDK never made it into 81. 82 is cancelled. The first version that supports the SDK is Edge 83, but unfortunately Microsoft created a bug that will hang the initialization of the browser and also makes fallback fail. Bug is tracked here (https://github.com/MicrosoftEdge/WebViewFeedback/issues/151). So the only Edgium (new edge) build that works, is the Canary channel version, which can be downloaded at:
Get Started.
The instructions to get started vary depending on which platform you want to create the application for. It's bestto follow the tutorials for every platform. They are available below:
Some guidance on how to set up a Blazor project to best accommodate targeting multiple platforms is available as well.
Install the NuGet Packages.
In general, you need to add one of the NuGet packages specific to your platform to your project:
Add BlazorWebView to Your Activity/View, ViewController/View, or Window.
Next add the BlazorWebView (it's named like this in every package) to your Activity / View (for Android),ViewController / View (for iOS and Mac), or your window XAML. Make sure that the BlazorWebView gets anidentifier so we can reference it in a code-behind file.
Wire up Your Blazor Project to the BlazorWebView.
Mono Download Mac
First, we need to adapt the URL to the Blazor JavaScript. It will be loaded from the NuGet assembly byreferencing a dedicated scheme. The URL to the Blazor JavaScript is:
The rest of the URLs are relative URLs. A complete example index.html file provided below:
Finally, we initialize the BlazorWebView from code-behind using the
BlazorWebViewHost
static class like this:Mono Framework Mac
That's it! That wasn't too difficult, was it?