Re: cannot get write access to registry

From: Egmont Gabler (info@gabler-systemtechnik.de)
Date: 10/08/02


From: "Egmont Gabler" <info@gabler-systemtechnik.de>
Date: Tue, 8 Oct 2002 11:44:37 +0200


Ok, I had forgotten the bool parameter to retrieve write access:
 RegistryKey key = Registry.LocalMachine.OpenSubKey("Company", true);
Egmont

"Egmont Gabler" <info@gabler-systemtechnik.de> schrieb im Newsbeitrag
news:anu7uf$je5$02$1@news.t-online.com...
> Trying to write to the registry within global.asax via "key.SetValue()"
> Visual Studio.NET allways throws an UnauthorizedAcessException. I'm using
> the following code within a simple C# Webserver application:
>
> RegistryPermission f = new
> RegistryPermission(RegistryPermissionAccess.AllAccess,
> "HKEY_LOCAL_MACHINE\\Software\\Company");
>
> RegistryKey key = Registry.LocalMachine.OpenSubKey("Company");
> try
> {
>
> key.SetValue("Version", "3.08");
> }
>
> catch (UnauthorizedAccessException e)
> {
> }
>
> I included the RegistryPermission - code hoping to solve the problem, but
> without success. My system settings:
> 1) In Win2000 Professional I'm logged in as user with administrator
> privileges.
> 2) The "ASPNET user" is also member of the administrator group.
> 3) In my Web.config within <system.web> there is defined <authentication
> mode="Windows" /> and <identity impersonate="true" />
>
> Whats missing or wrong? Thanks for any suggestions?
> Egmont
>
>
>
>