How to fix .NET Framework performance counter problems in XP Embedded

I posted this item a while back in the newsgroups but I wanted to put it in my blog also because I think it may have gotten a little buried amongst all the posts there. We have seen many reports of bugs related to calling into performance counter APIs on XP Embedded. These have shown up most commonly when using the System.Diagnostic.Process class in the .NET Framework but can also be seen when using certain native APIs. The underlying issue is a registry key that is incorrectly populated when creating an XP Embedded image. This issue will be fixed in the upcoming XP Embedded SP2 release, but I
also wanted to provide a couple of workarounds that can be applied in the

If you have not yet built your XP Embedded runtime, you can do the

  1. Choose all of the components you want in your runtime and check dependencies in Target Designer
  2. Go to the View menu and make sure the Resources item is checked
  3. Expand the Performance Counter Configuration component in the component viewer for your runtime and choose Registry Data
  4. Right-click on the key named HKLM\Software\Microsoft\Windows NT\CurrentVersion\Perflib\009\ and choose Disable
  5. Build your runtime with that key disabled so it will not appear by default

If you have already built your runtime, you can delete the registry key named HKLM\Software\Microsoft\Windows NT\CurrentVersion\Perflib\009\ and then reboot your machine to fix this issue.