Upgrading OCX loses OCX registration

NigelB
NigelB used Ask the Experts™
on
In VB6 SP3 I had created an OCX which had succesfully registered and was being used in a number of other VB apps.

I added some features and rebuilt the OCX in VB.  Now I can't get VB to recognise the fact the OCX exists.  If I try to create a new project and choose the OCX from the Components list, I get the error message "blah.ocx could not be loaded".  All my existing projects using this component are now broken too.

I have tried registering it with regsvr32 (which returns success), unregistering and then re-registering it (which also returns success), rebuilding the OCX with a different name, but nothing works.  There are no errors when compiling the OCX.

How can I get my existing projects to use the upgraded OCX?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Remove the other instances of the OCX from the registry.  If you have the old OCXs, run regsvr32 /u OCXName to remove them from the registry.  Then just for safety, re-register your newest OCX.  If you don't have the old OCX in binary form, then you've got to delete the entries manually from the registry.

What's happening here is that you have an old reference to the OCX, but probably don't have the old OCX binary file.  To see this, go into VB, select Project...Components and see how many instances of your control show up.  Note:  This is probably the result of you not setting Binary or project level compatibility on the OCX project.

Author

Commented:
I've run the regsvr /u repeatedly!  The component doesn't show up in VB Components list after doing this once, although regsvr doesn't complain now matter how many times I unregister the component.

Re-registering the component makes it show up but doesn't allow me to select it from the list.

Where should I be looking in the Registry?  
do a search on the component name.  Delete all references to it that you are sure are related to your component.  This is a dangerous proposition, so I recommend taking a backup of the registry before you start.  You can do this by doing an export registry file while in Regedit.

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
OK - thought that was what you were going to suggest, so did it.

The following describes the results...

I can re-register the old binary and everything works fine.

Upon upgrading the binary (using Binary level compatibility) then gives VB errors, cannot load blah.ocx.  This occurs when loading existing projects or trying to create new projects with this OCX.

Building a new binary from the existing code has the same effect - cannot load blah.ocx.

This now sounds like an internal compilation issue, that VB is detecting an error but not reporting it, or a Windows issue, that the registration says it works but doesn't really.  Am I right?
Well, not exactly.  If you load the OCX project into VB and VB complains that it cannot build it, and you can build the old OCX, then the answer is in the new functionality that you gave to the new OCX>  You may have added something like a reference to the Common Dialog or another control that you didn't have in the old OCX.  The problem is probably with that reference, not your own.

Author

Commented:
Hmm.  VB is not complaining it can't build it.  In fact it gives the impression that it has built it quite successfully.  It's complaining whenever I try to use the rebuilt one, stating that it can't load the component.  And Mr Careless here does not have the source code (now) to build the original one!  As far as I am aware, the only code added is additional functions, variables and events.  It's a simple control really - only has a text box in it.
OK, unregister the component.  Turn off the Binary compatibility and let it get an new GUID, then use the component in a new project.  Same problem?

If not, then you still have remnants in the registry of the old component, but they should not matter anymore.  The remnants are probably GUID based, not component name based.  Cleaning the registry is a touch nut to crack.  If you want to try to get all the old references off your machine do this:

1) Backup the registry as mentioned earlier
2) rename the component file to MyFile.ocXXX or something.
3) Obtain a copy of Regclean
4) run Regclean as many times as necessary until you don't get the option "Fix Errors"
5) rename your component back and perform regsvr32 on it

All should be well with the world again.

Author

Commented:
Hi there,

I haven't forgotten - we've got builders in at the moment and life is rather busy.  You may be right in that I built the renamed component with binary compatibility on, but I will check in the next week or two.

Cheers
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
- points to twalgrave
Please leave any comments here within the
next seven days.
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial