Mono

Mono is an open-source and cross-platform implementation of the .NET Framework. Wine can use a Windows build of Mono to run .NET applications.

For Wine releases 1.5.3 and later, the Wine Mono package is recommended. For earlier versions, an official Windows release of Mono 2.10 is recommended.

Wine 1.5.6 will install Wine Mono automatically as needed. It will search for the MSI in the following locations:

  • The Unix directory stored in the "MonoCabDir" value at HKCU\Software\Wine\Dotnet.

  • /usr/share/wine/mono, or possibly some substitution for /usr if Wine was installed to a different location.
  • wine_build_directory/../mono, if Wine is being run from a build tree.
  • Download from http://source.winehq.org/winemono.php

Unlike gecko, there is only one package containing the code for both x86 and x86_64, as most of the code does not depend on the architecture.

Users who want to avoid download prompts can run the script http://winezeug.googlecode.com/svn/trunk/install-addons.sh to install both gecko and mono in /usr/share/wine.

The Mono package should always be removed before installing native .NET. This can be done with the following command-line:

$ wine uninstaller --remove '{E45D8920-A758-4088-B6C6-31DBB276992E}'

For build instructions, see the readme at https://github.com/madewokherd/wine-mono

Debugging

As of Wine Mono 0.0.4, the WINE_MONO_TRACE environment variable may be set as follows to trace calls within Mono:

    all                  All assemblies
    none                 No assemblies
    program              Entry point assembly
    assembly             Specifies an assembly
    wrapper              All wrappers bridging native and managed code
    M:Type:Method        Specifies a method
    N:Namespace          Specifies a namespace
    T:Type               Specifies a type
    E:Type               Specifies stack traces for an exception type
    EXPR                 Includes expression
    -EXPR                Excludes expression
    EXPR,EXPR            Multiple expressions
    disabled             Don't print any output until toggled via SIGUSR2

This option is the same as the --trace option in Mono.

Note that "All assemblies" includes the program itself and all libraries shipped with it. Mono is capable of tracing any .NET code. You probably should avoid the "all" trace if there might be proprietary code running in the process.

Activating any trace at all, even a bogus assembly name, will cause Mono to print out all exceptions as they occur. This can be useful, but it can also be misleading as some exceptions are perfectly normal.

If you're not sure which libraries might be involved in a problem, and no exceptions are being raised, try WINE_MONO_TRACE=wrapper. It tends to be low-traffic while also containing useful information.

In earlier versions of Wine, the "MONO_TRACE" environment variable may work.

If you see "Stacktrace:" in the console, this means that Mono has crashed. To debug, set MONO_DEBUG=suspend-on-sigsegv. You will then see "Received SIGSEGV, suspending..." after the crash, and you can attach winedbg to the process.

Documentation

Standard .NET namespaces and classes are documented at MSDN here: http://msdn.microsoft.com/en-us/library/w0x726c2.aspx

Runtime detection

As of 1.3.7, Wine will search for a Windows install of Mono in the following locations:

  • c:\windows\mono\mono-1.0 or mono-2.0
  • If Wine is installed, <prefix>/share/wine/mono/mono-1.0 or mono-2.0, where <prefix> is usually /usr or /usr/local.

  • If Wine is run from a build tree, wine/../mono/mono-1.0 or mono-2.0
  • The path specified in the registry, if Mono was installed via the official Windows installer.

The Wine Mono package installs its files in c:\windows\mono\mono-2.0. In modern Wine (>= 1.5.6), without Wine Mono installed it will appear to Windows applications that .NET is not installed, so the only real option is to use that package.

Test Suite

See http://www.mono-project.com/Testing first.

Running the Mono test suite on Wine is very important for fixing bugs (in Mono and in Wine), and I suspect that MS .NET hosted in Wine will also benefit from some of the fixes made for the Mono tests.

The Mono build system has make targets for running tests, but using them on Windows or Wine requires building Mono with cygwin or doing strange things to the build system. To make this easier, the build script for wine-mono will create self-contained builds of the Mono test suite when run with the -t switch. These tests are located in directories named like tests-net_2_0.

To run tests, run nunit-console.exe with the dll file containing the tests as an argument. For example, to run the System.Drawing tests:

wine nunit-console.exe System.Drawing_test_net_2_0.dll

You could also invoke nunit-console.exe using Mono, or on a Windows machine from a command prompt. NUnit is actually a general-purpose unit testing framework for .NET, which Mono happens to use, and it should work on any .NET impelementation.

You can use the /fixture or /run switches to run only a single related set or tests or a single test.

Note that the tests are marked based on whether they are expected to work on various platforms, and running them in this way will include tests that are known not to work in Mono. One would have to use the /exclude switch to change this.

Microsoft .NET

If you need to use Microsoft's implementation of the .NET framework, the Microsoft runtimes can partly run on Wine. You can find tips and share comments with other users at the .NET AppDB page.

You can install the appropriate version of Microsoft's .NET runtime (dotnet35, dotnet30, dotnet20, or dotnet11) through winetricks. Be aware though, that your .NET application still might not work (at least not yet), and Microsoft's .NET runtimes are not free software so be sure to read the EULA before accepting. Mono, on the other hand, is free software, supported by a strong community, and probably a better choice if it works with your application.


CategoryDevelopment CategoryQualityAssurance CategoryThirdParty CategoryApplication

Mono (last edited 2013-12-07 05:05:54 by VincentPovirk)