views:

19

answers:

1

I've recently been working on a C#/VS2008 project which requires 3 ActiveX controls. I created a .NET wrapper using AxImp.exe for the controls, and added them as references to my project. The code had been working without any trouble for a few days.

Yesterday, I pulled a clean version from our version control server (the wrapper DLLs were included, but not the ActiveX controls themselves), and when I attempted to run the program, I get a COMResultException with HRESULT = REGDB_E_CLASSNOTREG(0x80040154) during the InitializeCompnent call of the parent form.

Any clues on what might have happened to cause this?

+1  A: 

Not sure what "clean version" means but clearly the GUIDs in the interop library no longer match the GUIDs used by the ActiveX controls. Getting 0x80040154 is the result, it can no longer find the ActiveX registry keys.

Controlling the build process and keeping the ActiveX controls in sync with the interop wrappers is pretty important or you'll be battling this problem long-term. Generating them ought to be associated with building the controls. This can be especially a problem if the controls were created in VB6. It is quick to assign new GUIDs unless you setup its binary compatibility feature.

Hans Passant
How do the GUIDs for the ActiveX controls change? I would have thought that they would stay the same (but then again, I don't know much of anything about ActiveX GUIDs). Also, is there a way to use the "Add Reference..." dialog to generate the ActiveX control, and would that solve the GUID update problem? When I attempt to use it, the Ax* namespace/classes don't show up. Forgive my ignorance, I'm pretty new at this
Ian Meinzen
I don't know, talk to the guys that maintain the ActiveX controls. Changing GUIDs is a requirement in COM if the public interface changed, it avoids DLL Hell. The bad kind, not this kind. No, you need aximp.exe if you want to put the control on a form.
Hans Passant
So how can you check the CLSID the Interop DLL is looking for? When I pause the debugger, I see something promising in the control->base->clsid, but I figure it could be something else. I removed the references from my project, unregistered the OCX, deleted the Interop DLLs, re-registered the OCX, then used AXIMP to regenerate the DLLs, then re-add the reference, and still no dice. Is there any way to confirm which ActiveX control it is trying to load, and likewise check to see if it is registered appropriately?
Ian Meinzen
Are you running the 64-bit version of Windows?
Hans Passant
Yes, I am. (I'm using the AxImp.exe in C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin, since the one in the x64 doesn't appear to work). The program is being compiled as x86.
Ian Meinzen
You'd better double-check the Platform Target setting, also for the Release configuration. And make sure you use the right version of Regsvr32.exe to register the controls, the 32-bit version is in c:\windows\syswow64. More here: http://stackoverflow.com/questions/1889941/64-bits-stuff-for-c-development/1890173#1890173
Hans Passant
That was the problem - the clean check-out blew away the platform setting I had been using. Thanks for all of the help!
Ian Meinzen
Score one for psychic debugging.
Hans Passant