[IronPython] Calling COM method returns generic System.__ComObject?

Dino Viehland dinov at microsoft.com
Thu Aug 12 23:14:06 CEST 2010

Does just "opc_items_object.AddItem" work at all?  That should work if it's an IDispatch com object or if it has IProvideTypeInfo.

If not the workaround is to use the interface to dispatch through as you've discovered.  Rather than constructing an object with the interface though you do:

IComInterface.AddItem(comObject, 'OPC path here', opc_grp_object.ClientHandle)

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of yngipy hernan
Sent: Wednesday, August 11, 2010 7:21 PM
To: Discussion of IronPython
Subject: [IronPython] Calling COM method returns generic System.__ComObject?

Hi All,

I have been playing around IronPython + COM + OPC (COM not the .Net).

One of the calls in OPC is (pseudocode):

item = opc_items_object.AddItem('OPC path here', opc_grp_object.ClientHandle)

The issue is that item is returned as System.__ComObject. All methods that are available for OPCItem interface are gone???

I have search the internet and it seems like opc_items_object should have a coclass for IronPython to figure out how to return object properly. Unfortunately this is not the case, based on the IDL OPCItems don't have a coclass definition.

Is there a work-around for this?

I have also come across a possible work-around by using unbound class instance, i.e., outParamAsReturnValue = InteropAssemblyNamespace.IComInterface(comObject).

But I can't figure out how to use it.

I would really appreciate anyone can point me out to the right direction.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100812/81946940/attachment.html>

More information about the Ironpython-users mailing list