Bug 26024 - Create /etc/mono/registry with read / write permissions when installing the package
Summary: Create /etc/mono/registry with read / write permissions when installing the p...
Alias: None
Product: Installers
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Linux
: Normal normal
Target Milestone: packaging-changes
Assignee: Jo Shields
Depends on:
Reported: 2015-01-14 12:19 UTC by guillaume.turri
Modified: 2016-08-30 08:31 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description guillaume.turri 2015-01-14 12:19:58 UTC

TL;DR: The debian package should create /etc/mono/registry with 766 permissions, in order to make it easier to use.


I hope it's the good place to report this inconvenience I experienced on Ubuntu 14.04 with the mono packaged installed from the mono-project repo. Please feel free to redirect me if it's not the case.


Several C# libraries uses Windows registry. For system wide keys, this is replaced by files under /etc/mono/registry. So by default, if a user install the mono package, and tries to run such an application, it will crash with a System.UnauthorizedAccessException.

Of course, when we know where it comes from, it's easy to work around (just create this directory ourselves, or set MONO_REGISTRY_PATH). However, it's not that intuitive, and googling on /etc/mono/registry we can see that several people are clueless against this issue.

- http://lists.ximian.com/pipermail/mono-list/2008-July/038996.html
- http://stackoverflow.com/questions/24872394/access-to-the-path-etc-mono-registry-is-denied
- http://www.cafe-encounter.net/p1606/mono-mvc-unauthorizedaccessexception-access-to-the-path-mono-registry-is-denied

How to reproduce

Install the mono package on an Ubuntu system and try to run the following code:

    using System;
    using Microsoft.Win32;

    public class Program {
      public static void Main(){
        Registry.SetValue (@"HKEY_USERS\myKeyName", "myValueName", "myValue");

Expected: it doesn't crash
Actual: it crashes with a System.UnauthorizedAccessException
Comment 1 Arsen.Shnurkov 2016-08-25 07:57:25 UTC
I have the same bug when installing from sources with ebuilds
Comment 2 Jo Shields 2016-08-30 08:31:24 UTC
It is not expected for non-root users to have write access to the entire registry, on Windows - several hives are intentionally read-only unless Administrator.

We mirror this - HKEY_CURRENT_USER is saved to ~/.mono/registry, the rest require root.