views:

1077

answers:

5

Good afternoon,

I have been trying to load a OCX file into one of my VB6 projects for most of the day today. I've tried checking the COM registration in the registry the best that I know how, and have attempted several times using REGSVR32 on the file to no avail. All I keep getting from VB6 when I try to load the component (Under Project --> Components) is 'FilePath\FileName.ocx' could not be loaded. Has anyone else seen this before, and if so, any ideas how to fix it?

Thanks!

+3  A: 

Just a couple of tips to help isolate the problem....

Look at the control with OleView

Examine the name: if it is one of the reserved words such as 'Menu', vb6 will fail to load it. (Although vb6 will happily let you create (and use) one with a bad name until it is saved and reloaded)

Examine the interface: does it describe the functionality? You may have a damaged or unlicensed ocx.

Attempt to load it with the ActiveX Control Test Container... If you can, the problem is with VB6 and not the ocx.

CMB
In OleView use File->View Typelib on the OCX and notice the importlib lines. For instance importlib("oleguids3.tlb"); means that this tlb is needed to be registered on the dev machine before referencing the OCX. The reason is that if a library is referenced by the [external] interfaces of the OCX then it should be registered on the dev machine or the OCX is unusable in the IDE.
wqw
A: 

When you say you have used "REGSVR32 on the file to no avail" do you mean that you get a file name succeeded message, or an error message? If registering the file succeeds CMB is likely right about the ocx being unlicensed.

Beaner
A: 

Licensing aside, there are a couple of other trip points with vb6. Especially if the OCX was developed in VB6.

If so, the 'officially' system registered version may conflict with the specific ocx you're using. In other words, both of them might have the same proper name (or classid) but the one you're attempting to use may not implement all the functionality described in the system registered one (i.e. you have a less evolved version). This arises when the author desires to maintain binary compatibility while enhancing the functionality of a control. As long as the public interfaces remain compatible, vb will not recalculate the classid.

You can fix this by forcibly unregistering the specific control (actually unregister all instances of the control). (regsvr32 /u control.ocx ) Then re-register the one you intend to use. Be certain that no running instance of VB6 exists when you do this or the results might not work. (Check your task list)

Hope that helps...

CMB
A: 

The control may be reliant on another DLL or OCX that may be missing or not registered and this could manifest itself as VB reporting that the control you're trying to use is missing. However, I'm not sure how you would identify the dependencies. As far as I know, dependency walker identifies static dependencies; I'm not sure if it can identify COM dependencies.

Jason Musgrove
A: 

This it may be a dependency issue -- some other component needed by the OCX is not present. Dependency Walker will find any static dependencies.

Jim Mack
Sure enough, this turned out to be a dependency issue. It sure has been a while since I fought with this one, completely forgot I had asked about it.
YodaJStarWars