无法读取注册表值C# [英] Cannot read the registry value C#

查看:318
本文介绍了无法读取注册表值C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

有一些问题:

我使用容错系统和Mi​​crosoft Windows Server 2008 sp2。

我试图获取注册表值的地方

Hi to All.
There is some problem:
I'm use fault tolerant system with Microsoft Windows Server 2008 sp2.
Where I try to get registry value as

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(@"Installer\Components\" + myBranch);
if (key.GetValue("1001") != null && (string)key.GetValue("1001") == myKey){
/*TODO: something*/}



应用程序返回错误:

对象引用未设置为对象的实例

在另一个窗口中版本全部工作



我尝试过:



我试过设置为用户对注册表的完全访问权限,使用C-libs获取注册表值。所有不起作用


Application return the error:
"Object reference not set to an instance of an object"
In another windows versions all is worked

What I have tried:

I tried set to user full access to registry, used C-libs for getting registry value..all isn't work

推荐答案

要做的第一件事就是找出哪一位是null:可能它是密钥但我们无法分辨。

因此要么使用调试器找出,要么添加代码以检查尝试创建子密钥后密钥的值是否为空值。如果是,则子项创建失败 - 这可能是权限问题(您是否需要管理员访问权限?)而不是我们可以从此处修复的任何内容。
The first thing to do is find out which bit is null: probably it's "key" but we can't tell.
So either use the debugger to find out, or add code to check if the value of key after the attempt to create the subkey is null. If it is, then the subkey creating failed - and that's likely to be a permissions issue (do you need Admin access?) rather than anything we can fix from here.


这篇关于无法读取注册表值C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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