Using Microsoft.Win32.Registry.GetValue() on Windows will lead to a SecurityException if the user does not have admin rights.
System.Security.SecurityException: A security error has been detected.
at Microsoft.Win32.Win32RegistryApi.GenerateException (Int32 errorCode) [0x00000] in <filename unknown>:0
at Microsoft.Win32.Win32RegistryApi.OpenSubKey (Microsoft.Win32.RegistryKey rkey, System.String keyName, Boolean writable) [0x00000] in <filename unknown>:0
at Microsoft.Win32.RegistryKey.OpenSubKey (System.String name, Boolean writable) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) Microsoft.Win32.RegistryKey:OpenSubKey (string,bool)
at Microsoft.Win32.Registry.ToKey (System.String keyName, Boolean setting) [0x00000] in <filename unknown>:0
at Microsoft.Win32.Registry.GetValue (System.String keyName, System.String valueName, System.Object defaultValue) [0x00000] in <filename unknown>:0
at Smuxi.Frontend.Gnome.Frontend.InitGtkPathWin () [0x00000] in <filename unknown>:0
at Smuxi.Frontend.Gnome.Frontend.InitGtk (System.String args) [0x00000] in <filename unknown>:0
at Smuxi.Frontend.Gnome.Frontend.Init (System.String args) [0x00000] in <filename unknown>:0
at Smuxi.Frontend.Gnome.MainClass.Main (System.String args) [0x00000] in <filename unknown>:0
I could track the issue down to the code in Registry.cs:
The 2nd parameter of OpenSubKey() asks for write permission. It should simply pass the "setting" variable instead.
I will create a PR with a tested fix.
Created attachment 8975 [details]
Repro of the bug
Created attachment 8976 [details]
The original report was in Smuxi, which can be found here:
Pull request: https://github.com/mono/mono/pull/1445
Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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.
Create a new report for Bug 25106 on Developer
Community or GitHub if you have new information to add and do not yet see a matching
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
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.