‘Class Not Registered’ in VS2008 on x64

Took a while to figure this one out, but in hindsight, it’s painfully obvious. I switched from XP 32-bit to Win7 64-bit last week, and just got Visual Studio loaded back up. I opened up one of my projects, hit run, and started getting COM exceptions about a class not being registered.

After a while, I finally found that the default compile options will compile for ‘Any CPU’, which will compile your project for the CPU you are on currently. You can change this by going into your project properties, Compile tab, and clicking Advanced Compile Options. Setting the Target CPU to x86 solved the problem for me.

Not all COM components will require this. It just so happened that one I was using was designed for 32-bit development environments only.