[Ironpython-users] System.__ComObject: method or operation not implemented
evan.davey at ekidna.io
Thu Aug 20 01:29:11 CEST 2015
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.
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.
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
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.
Email: evan.davey at ekidna.io
Mobile: +61 403 467 661
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users