Access to remote registry (RegistryPermissionAttribute)

From: Marc Wuergler (marc_wurgler_at_hotmail.com)
Date: 08/20/04


Date: Fri, 20 Aug 2004 15:20:32 +0200

Hi !

I'm trying to access a registry key on a remote computer.

Here is my code :

[RegistryPermissionAttribute(SecurityAction.RequestMinimum, Read =
@"HKEY_LOCAL_MACHINE\SOFTWARE\MyKey")]
public static string ReadRegistryKey(string PsMachineName)
{
    try
    {
        RegistryKey LoKey =
RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, PsMachineName);
        RegistryKey LoSubKey = LoKey.OpenSubKey(@"SOFTWARE\MyKey");
        string LsValue = LoSubKey.GetValue("InstallFolder").ToString();

        return LsValue;
    }
    catch(Exception e)
    {
        return e.Message;
    }
}

This code does not compile !!!

Error : Error emitting
'System.Security.Permissions.RegistryPermissionAttribute' attribute --
'Common Language Runtime Internal error: 0x8013143e'

Could anyone tell me what I'm doing wrong or how I can fix this !? Thanks a
lot.

Marc



Relevant Pages

  • Re: PcAnywhere & Ports to Open
    ... Taking a moment's reflection, Lars M. Hansen mused: ... | There's a registry key you can add/modify on the remote computer to ... Create the following Registry key: ... Making changes to the registry MAY cause problems with your ...
    (comp.security.firewalls)
  • Re: Problem about "StdRegProv" method
    ... > application queries one registry key in remote computer. ... > I uses another account name and password to connect to this remote ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Access to remote registry (RegistryPermissionAttribute)
    ... To access the registry key with a specific user, I need to give that user ... > version of the CLR are you seeing this behavior on? ... rights. ... >>I'm trying to access a registry key on a remote computer. ...
    (microsoft.public.dotnet.security)

Quantcast