RegistryKey.DeleteValue fails with UnauthorizedAccessException
From: Chris Rigg-Milner (anonymous_at_discussions.microsoft.com)
Date: 03/26/04
- Next message: rgilmore: "Anonymous access required for .NET web services?"
- Previous message: Jonathan Ruckert: "RE: ? - Database Query & Saving to Application Cache"
- Next in thread: Chris Rigg-Milner: "Please Ignore - Solved it myself"
- Reply: Chris Rigg-Milner: "Please Ignore - Solved it myself"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Fri, 26 Mar 2004 03:56:07 -0800
Can somebody help? Why can I not delete a registry key value?
I have a WinForms app that needs to delete a registrykey value but fails with a UnauthorizedAccessException.
OS = XP Pro 1.1a, Framework = 1.1, language = C#
The command that fails is RegistryKey.DeleteValue(sKey,true);
This happens when using my restricted developer account and also if I run under an administrator account.
I can delete these keys using regedit quite happily from my developer account.
The namespace has the following decoration
[assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum,All = "HKEY_CURRENT_USER")]
namespace xxxx
which I assumed would allow me all the acces I required
When I look at the .exe with permview I get the following:
minimal permission set:
<PermissionSet class="System.Security.PermissionSet"
version="1"><IPermission class="System.Security.Permissions.RegistryPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, publicKeyToken=xxxxxxxxxxxxxx"
version="1"
Read="HKEY_CURRENT_USER"
Write="HKEY_CURRENT_USER"
Create="HKEY_CURRENT_USER"/></PermissionSet>
I am basically now dazed and confused. Can anybody explain why my program fails but regedit allows this deletion. Also what do I change to get app to do the delete?
Thanks in anticipation.
- Next message: rgilmore: "Anonymous access required for .NET web services?"
- Previous message: Jonathan Ruckert: "RE: ? - Database Query & Saving to Application Cache"
- Next in thread: Chris Rigg-Milner: "Please Ignore - Solved it myself"
- Reply: Chris Rigg-Milner: "Please Ignore - Solved it myself"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|