HELP! win32com, COM, Invoke problem

Mark Hammond MarkH at ActiveState.com
Tue Jan 2 19:45:02 EST 2001


TB wrote:

> Mark, thanks for your quick reply.
> 
> I did notice that if you I take out the parens, this statement will
> work, but when it bombs at the next statement:
> 
> bo = form.CreateBO("Clarify.CBO.Generic")
> the error message is
...

>     ret = self._oleobj_.Invoke
> (retEntry.dispid,0,pythoncom.DISPATCH_PROPERTYGET,1)
> com_error: (-2147352567, 'Exception occurred.',
> (0, 'Form.CreateBO', 'Invalid class string\015\012', None, 0, -
> 2146827287), None)

The COM object is returing this error.  It appears that it expects 
"Clarify.CBO.Generic" to be registered as a class in your registry.

> the exception is thrown at the same Invoke line in dynamic.py. This
> time CreateBO requires one parameter, but when it's called with Invoke
> (...DISPATCH_PROPERTYGET,1), it didn't thrown an exception of
> BADCONTEXT, but it threw a 'Invalid class string', is it a bug in the
> control I'm using?

It looks like the control is purposely throwing this error.


> As for Makepy, I tried before but it didn't help. Let me make it more
> clearly. The Clarify.CBO.App.1 sits in a DLL called BOCLIENT.DLL, but
> all other stuff, session, FormContext etc sits in another DLL called
> AXCOMMON.OCX. After I ran makepy on both files, I saw 2 py files
> created, but when I step through the program I found it only used the
> 1st py file, not the 2nd one, which contains FormContext and etc. I
> don't know COM so I can't explain why. Could you explain a little bit?

You may have trouble with an OCX.  Python doesn't really support them. 
Pythonwin does to some degree - check out pywin\demos\ocx.

Re makepy:  Each COM object has a method "GetTypeInfo()".  If this 
method works and provides the CLSID of the object, then the makepy 
system can locate and load the correct module.  This is the basis of how 
makepy works.  However, in some cases, even though makepy has been run, 
the COM object does not report its CLSID.  In this case, Python is 
unable to load it.

However, in no case is the entire set of makepy generated files loaded - 
so you wont see a makepy generated file loaded until a COM object it 
describes is first used.

Mark.




More information about the Python-list mailing list