带有OpenSubKey的Registry.LocalMachine产生'System.Security.SecurityException' [英] Registry.LocalMachine with OpenSubKey yields 'System.Security.SecurityException'

查看:80
本文介绍了带有OpenSubKey的Registry.LocalMachine产生'System.Security.SecurityException'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行以下内容:

I am trying to run the following:

RegistryKey rk = Registry.LocalMachine;

RegistryKey softwareKey = rk.OpenSubKey(" Software" ;,
$
                                   RegistryKeyPermissionCheck.ReadWriteSubTree);

RegistryKey rk = Registry.LocalMachine;
RegistryKey softwareKey = rk.OpenSubKey("Software",
                                           RegistryKeyPermissionCheck.ReadWriteSubTree);

在调试器中。 我的帐户有管理权限,但我在第二行代码上遇到异常'System.Security.SecurityException'。

in the debugger.  My account has administrative privileges, but I get exception 'System.Security.SecurityException' on the second line of code.

有没有办法运行这个调试器中的代码? 或者我做了一些愚蠢的事情?

Is there no way to run this code in the debugger?  Or am I doing something stupid?

我正在运行Windows 7 Pro,Visual Studio 2010。

I am running Windows 7 Pro, Visual Studio 2010.

谢谢你提前,

Michael Bate

Thanks in advance,
Michael Bate

推荐答案

E;是的对HKLM的读/写访问需要特权。 

E;levated privilege is needed for read/write access to HKLM. 

管理员组成员启动的UAC启用进程以受限用户权限运行,除非它们以"以管理员身份运行"启动或者表现为"requireAdministrator",这两者都会导致新进程
以提升的权限开始。

With UAC enabled processes started by members of the Administrators group run with Limited user privileges unless they are started with "run as Administrator" or are manifested to "requireAdministrator", both of which cause the new process to start with elevated privileges.

使用"启动Visual Studio" ;以管理员身份运行"这样它就会升高。 您现在应该能够调试代码

Start Visual Studio with "run as Administrator" so that it is elevated.  You should now be able to debug your code


这篇关于带有OpenSubKey的Registry.LocalMachine产生'System.Security.SecurityException'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆