Help! registry access in Class library RRS feed

  • Question

  • I'm making class library(dll) but there is some problems. I can't access registry.

    here is code snippet.

                        int lastSelected = 0;
                        lastSelected = (int)Registry.CurrentUser.OpenSubKey("Software\\MyApp", true).GetValue("lastSelected");
                        MessageBox.Show("value: " + lastSelected.ToString());

    This project build fine, but the code not work, with no error messages. (MessageBox didn't show up)


    I also add below code in AssemblyInfo.cs file.

    [assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum, ViewAndModify = "HKEY_CURRENT_USER\\Software\\MyApp")]

    I don't know what's wrong.

    Sunday, May 16, 2010 7:55 AM


All replies