4

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?

Jeff LaFay
  • 11,884
  • 12
  • 70
  • 97
Jason Lowenthal
  • 770
  • 1
  • 5
  • 16

8 Answers8

4

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
  • 486
  • 3
  • 6
  • 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 Jul 14 '09 at 11:26
3

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
  • 776
  • 4
  • 1
  • 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. – Jason Lowenthal Aug 20 '10 at 20:47
2

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.

1

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
Nathan Tuggy
  • 2,239
  • 27
  • 28
  • 36
Licid
  • 11
  • 1
0

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.

jac
  • 9,286
  • 2
  • 28
  • 60
0

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
  • 486
  • 3
  • 6
0

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
  • 3,506
  • 17
  • 14
0

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

Thanks everyone