title: RegistryKey.GetSubKeyNames throws IOException
body: <p>When using <a href="http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.getsubkeynames.aspx" rel="nofollow">RegistryKey.GetSubKeyNames</a>, an IOExeption is thrown: </p>
  
  <blockquote>
    <p>"No more data is available"</p>
  </blockquote>
  
  <p>Here is the relevant code:</p>
  
  <pre><code>string subKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products";
  RegistryKey key = Registry.LocalMachine.OpenSubKey( subKey );
  string[] keys = key.GetSubKeyNames(); // throws IOException here
  </code></pre>
  
  <p><strong>Specs</strong><br /></p>
  
  <ul>
  <li>Win7 x64</li>
  <li>VS 2010 SP1</li>
  <li>.NET 3.5</li>
  </ul>
  
  <p>The exception is thrown when using a build type of "Any CPU"; when using a build type of "x86" the code executes as expected, but reads the keys from the "Wow6432Node" instead of the SubKey path named in the defined <code>subKey</code> string variable above.</p>
  
  <p><strong>The question is</strong>: how can I read all the SubKeys in the <code>subKey</code> path defined above on a 64-bit system (not the Wow6432Node)?</p>
  
  <p>Of note: When I run the same code on another 64-bit system, the code executes without error. I'm almost inclined to think I may have a corrupted registry key somewhere? If so, any ideas on how I can find the corrupt key?</p>