[Ironpython-users] System.__ComObject: method or operation not implemented

Evan Davey evan.davey at ekidna.io
Thu Aug 20 01:29:11 CEST 2015


HI,

I am trying to use Python to access an Application’s API that has been exposed in C#.  The API uses a client/server model via COM objects (main GUI is the client, functional blocks e.g. Schematic editor implemented as a server.

I have successfully called a number of API methods from python (e.g. to show a message dialog) in the application.

However, when I try to access the interface to the client or server, in Python I get back an object of type System.__ComObject (when these should be of type IClient or ISch_ServerInterface respectively) which then throws a method or operation not implemented error.

I have had some success calling methods via the unbound method e.g.

import DXP
client = DXP.GlobalVars.Client # of type System.__ComObject should be DXP.IClient

DXP.IClient.GetProductVersion(client) # works!

client.GetProductVersion() # throws method or operation not implemented error

Using this work-around would be fine, except that I am now encountering errors where the interface types have been extended e.g.

import EDP
import SCH
server = SCH.GlobalVar.SchServer # of type System.__ComObject should be SCH.ISch_ServerInterface

SCH.ISch_ServerInterface.CreateSchLibrary(server) # throws type has no attribute error
SCH.ISch_ServerInterfaceHelper.CreateSchLibrary(server) # this works


This works in C#

using EDP; // looks like the extension methods are implemented in here
using SCH;

SCH.ISch_ServerInterface server = SCH.GlobalVars.SchServer;
SCH.ISch_Lib lib = server.CreateSchLibrary();

Ideally, I would be able to do some kind of type cast in Python to allow me to use the objects naturally but can use the unbound method if the extension issue can be solved.  
I have tried using clr.ImportExtensons() without success.

Any help appreciated.

Best Regards,
Evan






 



Evan Davey

Ekidna
Email: evan.davey at ekidna.io
Skype: evan.j.davey
Mobile: +61 403 467 661
uk.linkedin.com/pub/evan-davey/4/982/91/ <http://uk.linkedin.com/pub/evan-davey/4/982/91/>
https://twitter.com/ekidna_io <https://twitter.com/ekidna_io>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20150820/a6417556/attachment.html>


More information about the Ironpython-users mailing list