Geeks With Blogs
James Norman
The first question any person would ask me is "Why are you still using ActiveX controls in 2015?  That's so 2003!"  That question, or rather veiled criticism, is never helpful to a developer asking for help. The simple answer is, sometimes you don't have a choice in the technologies you get to interact with.  

Let's start with this: I'm primarily a web developer/C# guy, who CAN work in Win32.  But it's not my strength.

Our company has created a lot of great products, and they have two main versions of one product: One which is HTML based, but requires a server to do most of the work, and a standalone ActiveX control which can have interaction with our server, but does not have to.  One of our main consumer products, is this fantastic 32-bit ActiveX control, in a nice Winforms wrapper.  The control is a very mature product that we all know has a limited future.

My job is to integrate this control in someone else's Windows-based product.  That exact situation is why it's a control in the first place.  

Thankfully, our ActiveX guru who is the lead programmer for this control, provided me with a starter solution as a template, as I always use the HTML-based solution.  When things just started to fail today, I racked my brain trying to figure out what I changed, but I could not remember.  When they did fail, it started with this error:

"Did not find a registered ActiveX control in {DLLLocation+Name}" and under "File" it said AXIMP.   I also got a Metadata file error as well, but that was because it couldn't compile the program after doing a clean then rebuild.

The first thing he tried to have me do is verify the control is registered.  So we did the standard regsvr32 for the dll that contained the control.  But I did it the lazy Windows way: right-click, "Open with...", "Microsoft Register Server." Massive failure ensued.  

The module {DLLNAME} was loaded but the call to DllRegisterServer failed with error code 0x80070005.

So he had me do it from an administrative command prompt next.   Bingo... everything worked.  Until I ran into the next problem.

Remember, I had started from a template, and while I have registered many DLLs in my life, ActiveX controls were something I had not done in a long while.  So he told me how he does it... simply add the control to the toolbox.  So right-clicking on the General area of the Toolbox, I chose "Choose Items" and immediately switched to COM Components so I didn't have to wait for it to load 6 billion .Net items.  Unfortunately, I cannot duplicate the exact dialog that I got, but it told me I couldn't add the control to the Toolbox.  No joy in Mudville, the Mighty Casey has struck out!  I thank him for trying (and he did help) but it was time for me to look even closer.

It got so desperate, I found the initial working template project and took it's project file and cut and pasted the ItemGroup in that had my ActiveX references.  Still a no go.  I was missing something.

I finally remembered we had mucked with some of the project properties earlier that day, trying to make sure something else worked.  I *did* change something and forget to set it back.  Something simple:
Project -> Properties -> Platform target: x64  I mentioned that to him and it's like "Oh, the ActiveX control is 32-bit!"   AHA!

That was at AnyCPU earlier, so let's change it back.  I went back to adding the control to the toolbox and this time I could add the control!  I then re-added it to my form, put back the code I had in there, and recompiled.  And all was good again.    

Another tidbit he gave me, is since that our control is designed to run in a web browser (well, IE) as well, that it wouldn't work for 64-bit Internet Explorer either.

While I likely will never run into this problem again, someone else might.  I couldn't find a real solution when Googling, so hopefully this post can help one or two people out, who have to work with legacy solutions.

Posted on Thursday, September 10, 2015 6:41 PM | Back to top


Comments on this post: Some ActiveX Pain

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © James Norman | Powered by: GeeksWithBlogs.net