views:

52

answers:

1

Hello,

in my python project I call a c++ dll using ctypes library. That c++ dll consists on a wrapper dll that calls methods of a c# com interop dll.

Sometimes I have a COM exception. I like to see what it corresponds exactlly but I don't know how to do it?

How can I attach the c++ debugger to this situation?

Thanks in advance

A: 

I don't know about your direct question, but maybe you could get around it by using comtypes to go straight from COM to Python instead sticking C++ in between.

Then all you have to do is:

>>> from comtypes import client, COMError
>>> myclassinst = client.CreateObject('MyCOMClass.MyCOMClass')
>>> try:
...     myclassinst.DoInvalidOperation()
... except COMError as e:
...     print e.args
...     print e.hresult
...     print e.text
...
(-2147205118, None, (u'MyCOMClass: An Error Message', u'MyCOMClass.MyCOMClass.1', None, 0, None))
-2147205118
None
Jorenko
but then can I get more info about what exception will be? Cause if you don't know, in this case, any exception gave by the c++ calls are COM exceptions ^^
aF
Yes; You get all the information that was included with the original exception, as members of the COMError object.
Jorenko
Edited to show how you can get the extra info from the COMError object.
Jorenko
I didn't need to go that far but thanks for the help :d
aF