tags:

views:

1070

answers:

4

I have a VB6 dll that is trying to create a COM object using the following line of code:

Set CreateObj = CreateObject("OPSValuer.OPSValue")

However this fails with the error "Object variable or With block variable not set".

I can see OPSValuer.OPSValue in dcomcnfg and it appears to be registered fine. Does anyone have any ideas about what may be causing the problem?

+3  A: 

It's possible that the class you are trying to instantiate is not installed correctly or is missing some dependencies. If you have access to OLE View, you can try instantiating that class outside of VB. If it won't instantiate then you have a bad installation or missing dependency. OLE View ships with Visual Studio, search for OleView.exe on your system.

It was located here on my system: D:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin

DMKing
A: 

The error may be thrown within the object initializing routine. That I don't find "OPSValuer.OPSValue" on Google makes me think it is custom code that encounters a bug.

Tomalak
OPSValuer.OPSValue is indeed our own component.
Phillip Wells
+2  A: 

DMKing is right about OleView. Also try looking at the control in Dependency Walker, any missing dependencies should come quickly to the surface.

Since this is a DCom component there also may be something failing in the components constructor, if anything fails in the constructor you will get that error. Is this a local DCom object or something running on another tier?

Instead of CreateObject try instantiating it with a standard New and see if it gives you a different error. Adding the reference itself may help out with determining that error. Is there a reason you are using late binding, rather than early binding?

Kris Erickson
It's a local DCOM object. We're using late binding because the method containing the CreateObject() call is passed in the name of the object to instantiate (OPSValuer.OPSValue in this case).
Phillip Wells
The cause does indeed seem to have been a problem in the constructor of the OPSValuer.OPSValue object.
Phillip Wells
A: 

Assuming OPSValuer.OPSValue is a component written in VB, this is probably an error raised in the Class_Initialize event of that component. If you have the source of the component it should be easy to debug.

Joe