Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight 4 WScript.regrad无法读取Windows 7下注册表中的新添加值_Silverlight_C# 4.0 - Fatal编程技术网

Silverlight 4 WScript.regrad无法读取Windows 7下注册表中的新添加值

Silverlight 4 WScript.regrad无法读取Windows 7下注册表中的新添加值,silverlight,c#-4.0,Silverlight,C# 4.0,我有一个Silverlight 4应用程序,在该应用程序中,我可以毫无问题地从HKLM分支读取现有注册表值,但如果我添加新值,读取将失败,出现FileNotFoundException。您可以在下面的代码中看到;第一次读取工作正常,但第二次读取我在注册表中添加的测试值失败 注意:我能够在Windows XP下阅读新添加的密钥;只是不在Windows7下 任何帮助都将不胜感激 if (Application.Current.InstallState == InstallState.Installe

我有一个Silverlight 4应用程序,在该应用程序中,我可以毫无问题地从HKLM分支读取现有注册表值,但如果我添加新值,读取将失败,出现
FileNotFoundException
。您可以在下面的代码中看到;第一次读取工作正常,但第二次读取我在注册表中添加的测试值失败

注意:我能够在Windows XP下阅读新添加的密钥;只是不在Windows7下

任何帮助都将不胜感激

if (Application.Current.InstallState == InstallState.Installed && Application.Current.HasElevatedPermissions)
{
    if (AutomationFactory.IsAvailable)
    {
        dynamic shell = AutomationFactory.CreateObject("WScript.shell");

        try
        {
            var resa = shell.RegRead(@"HKLM\SOFTWARE\Microsoft\.NETFramework\InstallRoot");
            var resb = shell.RegRead(@"HKLM\SOFTWARE\Microsoft\.NETFramework\Test");

            var regValue = shell.RegRead(DbTypeRegKeyName);
            var dbType = ExtractDbTypeFromId(regValue);
        }
        catch (FileNotFoundException fileNotFoundException)
        {
            throw new Exception(string.Format("Failed to read registry value '{0}' with error '{1}'.", DbTypeValueName, fileNotFoundException));
        }
    }
}

在32位版本的Windows下工作正常。结果表明,64位版本的Windows具有不同的注册表视图。在注册表中的WOW6432节点项下添加我的项解决了该问题