Can you try the typedproxy class which is on this bug: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=470 ?
It should work to wrap the object and let you access the various attributes that you want to by calling through the type (in this case the interface type - you'd pass IEventManager for the 2nd argument to the typedproxy). From: [email protected] [mailto:[email protected]] On Behalf Of Okko Willeboordse Sent: Monday, May 17, 2010 9:36 AM To: [email protected] Subject: [IronPython] Problems with 'unbound-class-instance' method Hello, I have some problems accessing an object. This object is instantiated by another object. This other object holds a reference to the object. This reference is of type MarshalByRefObject Obviously I cannot access the object through MarshalByRefObject. This must be done using the 'unbound-class-instance' method (please correct me if I am wrong) For this method you need to instantiate the interface type object. However the interface is abstract! How to cope with this. Please find sample code below; import traceback import clr clr.AddReference("Bosch.Vms.SDK") import Bosch.Vms.SDK # RemoteServerApi constructor instantiates an object implementing a Bosch.Vms.SDK.IEventManager # interface RemoteServerApi = Bosch.Vms.SDK.RemoteServerApi("xxxx", "xxxx", "xxxx") # RemoteServerApi holds a reference to the object implementing a Bosch.Vms.SDK.IEventManager # interface. This reference is of type MarshalByRefObject. print type(RemoteServerApi.EventManager) # How to call a method of EventManager through MarshalByRefObject? print Bosch.Vms.SDK.IEventManager.GetAllEventTypes try: # Try the naive approach. RemoteServerApi.EventManager.GetAllEventTypes() except: # Obviously fails because MarshalByRefObject instances do not support reflection. # AttributeError: 'MarshalByRefObject' object has no attribute 'GetAllEventTypes' print traceback.format_exc() try: # Try the 'unbound-class-instance' method Bosch.Vms.SDK.IEventManager.GetAllEventTypes(RemoteServerApi.EventManager) except: # TypeError: expected IEventManager, got MarshalByRefObject print traceback.format_exc() try: # Okay I need an IEventManager instance Bosch.Vms.SDK.IEventManager(RemoteServerApi.EventManager) except: # TypeError: Cannot create instances of IEventManager because it is abstract print traceback.format_exc() Okko Willeboordse
_______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
