Bug 3632 - Registry in linux doesn't support byte, ulong, ushort, bool when specifying DWORD as the ValueKind
Summary: Registry in linux doesn't support byte, ulong, ushort, bool when specifying D...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-02-24 08:32 UTC by David Ferguson
Modified: 2012-05-30 09:55 UTC (History)
3 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description David Ferguson 2012-02-24 08:32:53 UTC
The following method in the UnixRegistryApi class doesn't support ulong, ushort, bool, etc, when saving data to the registry.

public void SetValue (string name, object value, RegistryValueKind valueKind)

The following code works properly under .NET in windows:

internal static void SetRegistryValue<T>(RegistryKey regKey, Type propertyType, 
string propertyName, T propertyValue)
{
            if (propertyType == typeof(long) || propertyType == typeof(ulong))
            {
                regKey.SetValue(propertyName, Convert.ToInt64(propertyValue, CultureInfo.InvariantCulture), RegistryValueKind.QWord);
            }
            else if (propertyType == typeof(bool) ||
                propertyType == typeof(byte) ||
                propertyType == typeof(sbyte) ||
                propertyType == typeof(short) ||
                propertyType == typeof(ushort) ||
                propertyType == typeof(int) ||
                propertyType == typeof(uint))
            {
                regKey.SetValue(propertyName, propertyValue, RegistryValueKind.DWord);
            }
            else
            {
                if (propertyValue == null)
                {
                    regKey.SetValue(propertyName, String.Empty);
                }
                else
                {
                    regKey.SetValue(propertyName, propertyValue);
                }
            }
}

Note the property type of bool being set in the registry as a DWORD.  Also, looking at the code, the QWORD in the UnixRegistryApi doesn't support unsigned longs.
Comment 1 Miguel de Icaza [MSFT] 2012-02-24 17:30:15 UTC
Fixed
Comment 2 David Ferguson 2012-02-25 10:38:52 UTC
I noticed that the bool type will still fail when using a DWORD
Comment 3 Miguel de Icaza [MSFT] 2012-04-26 16:05:46 UTC
Can you test again, there was a separate fix that took care o f other cases.
Comment 4 Marek Safar 2012-05-30 09:55:30 UTC
Already fixed in master