Search code examples
comvb6dcom

"Object variable or With block variable not set" when attempting to create COM object


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?


Solution

  • 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?