开发者

Failed to read key HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx

开发者 https://www.devze.com 2023-03-30 07:40 出处:网络
I am trying to read registry keys from folder \"HKLM\\SOFTWARE\\Microsoft.NETFramework\\v4.0.30319\" Folder contains two keys SKUs and AssemblyFoldersEx开发者_运维技巧. First key is successfully reade

I am trying to read registry keys from folder "HKLM\SOFTWARE\Microsoft.NETFramework\v4.0.30319" Folder contains two keys SKUs and AssemblyFoldersEx开发者_运维技巧. First key is successfully readed, but second is failed (return null).

How to fix this?

C# code:

class Program
{
    static void Main(string[] args)
    {
        Microsoft.Win32.RegistryKey rkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs", false); // success
        Microsoft.Win32.RegistryKey rkey2 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx", false); // failed (returns null)
    }
}


Open your project in VS and go to Properties > Build then change Platform target to Any CPU then recompile. I suspect your Platform target is x86 and you are running on a 64 bit version of Windows.

Wow6432Node branch of the registry will get you every time :)

0

精彩评论

暂无评论...
验证码 换一张
取 消