Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

We fixed similar error recently. In our case the error was in the Visual Basic project (.vbp) file. Project file had been edited outside standardized build machine and contained references to OCX components - including workstation specific paths & versions of the components.

You can either edit the the project file in text editor or get a working version from version control.

Un-registering and registering again worked for me too.
Please note that you need to register this component using this syntax:

regsvr32 /i:design olch2x8.ocx

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.

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...

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.

Un register the Ocx re register the ocx then loaded the project again in VB6, it worked for me.

Thanks everyone

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top