I got my new Dell Studio XPS 16 laptop a couple of weeks ago with Windows 7 64-bit. The transition from Windows Vista 32-bit was pretty painless and everything seemed to work great. I did have some issues migrating my VS 2008 projects due to references to some dlls that were loacted in the C:\Program Files\ directory on my Vista machine but that are now located in the C:\Program Files (x86)\ directory. After fixing those issues everything seemed to run great and all my projects built successfully. I thought I was home free until I built and ran an Installer package that registered an ActiveX control. Depsite the fact that the control was registered on installation, I kept getting the following error when opening the form that utilized the ActiveX control:
System.Runtime.InteropServices.COMException (0x80040154): Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)) at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid) at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid) at System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid) at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid) at System.Windows.Forms.AxHost.CreateInstance() at System.Windows.Forms.AxHost.GetOcxCreate() at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state) at System.Windows.Forms.AxHost.CreateHandle() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.AxHost.EndInit() ...
I scoured the web and tried many different solutions including:
- Manually registering the dll
- Copying the dll to the C:\Windows\SysWOW64\ directory
- Registering the dll in the C:\Windows\SysWOW64\ directory
- And a bunch of other things that proved useless
The answer came from a blog post by Theo Gray. The issue was that VS 2008 was building the project to compile on “Any CPU” and apparently the ActiveX control is intended for x86 systems only. Given such, the project needed to be compiled for x86 systems only as well. Do the following to resolve the issue:
- Right click on the project title in the Solution Explorer.
- Click Properties.
- Click the Build tab.
- Select x86 from the Traget Platform ComboBox for both Debug and Release configuration.
- Build the project.
Alternatively, if you have multiple projects in a solution you can do the following to set this across all projects:
- Right click on the solution title in the Solution Explorer.
- Click Configuration Manager…
- In the Active solution platform select New…
- Select x86 from the first ComboBox
- Click OK
- Build the solution.
Thanks Theo Gray! Worked like a charm!