Failed to read key HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx
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 :)
精彩评论