The C# wrapper could be as simple as: public static class MyWrapper { public static void IServerInterfaceMethod(object o) { ((IServerInterface)o).IServerInterfaceMethod(); } }
Used like: MyWrapper.IServerInterfaceMethod(TransparentProxy) If you just want to call all static methods, or you can make an instance wrapper: public class MyWrapper { private readonly IServerInterface _wrapped; public MyWrapper(object wrapped) { _wrapped = (IServerInterface)wrapped; } public void IServerInterfaceMethod(object o) { _wrapped.IServerInterfaceMethod(); } } Used like: MyWrapper(TransparentProxy).IServerInterfaceMethod() Then you can pass around the wrapper object and just use it like a normal object. If you need to get back to the transparent proxy for some reason you could add a property which returns it. From: Muyal,Tsahi [mailto:tsahi.mu...@kla-tencor.com] Sent: Tuesday, October 11, 2011 3:01 PM To: Dino Viehland Cc: ironpython-users@python.org Subject: RE: .NET Remoting and Interface based objects The clr.Convert(TransparentProxy, IServerInterface) is failing with same exception I will code a C# wrapper but what does it mean? A client side assembly that will get the transparent proxy and convert it to the Interface type I need? Tsahi Muyal Corporate Platform Group(CPG) KLA-Tencor Israel From: Dino Viehland [mailto:di...@microsoft.com] Sent: Tuesday, October 11, 2011 11:46 PM To: Muyal,Tsahi Cc: ironpython-users@python.org Subject: RE: .NET Remoting and Interface based objects Hurm, maybe this is a different problem then... Does: import clr clr.Convert(TransparentProxy, IServerInterface).IServerInterfaceMethod() work? If not then my guess is you might need a C# wrapper :( From: Muyal,Tsahi [mailto:tsahi.mu...@kla-tencor.com] Sent: Tuesday, October 11, 2011 2:39 PM To: Dino Viehland Cc: ironpython-users@python.org Subject: RE: .NET Remoting and Interface based objects I tried using typedproxy class Not sure I am using it the right way This is what I did test = typedproxy(TransparentProxy, IServerInterface) test.IServerInterfaceMethod() This call is failing with "Expected IServerInterface, got MarshalByRefObject" I debugged the code to find out where it is failing, it is in typedproxy (I marked the line) class typedproxy(object): __slots__ = ['obj', 'proxyType'] def __init__(self, obj, proxyType): self.proxyType = proxyType self.obj = obj def __getattribute__(self, attr): proxyType = object.__getattribute__(self, 'proxyType') obj = object.__getattribute__(self, 'obj') att = getattr(proxyType, attr) att2 = att.__get__(obj, proxyType) #This line is throwing the exception return att2 Any idea? Thank you very much; Tsahi Muyal From: Dino Viehland [mailto:di...@microsoft.com] Sent: Tuesday, October 11, 2011 10:58 PM To: Muyal,Tsahi; ironpython-users@python.org Subject: RE: .NET Remoting and Interface based objects I'm not quite certain this is the same issue but you should try using the wrapper from this thread: http://lists.ironpython.com/pipermail/users-ironpython.com/2006-September/003549.html The transparent proxies always succeed when casting them to an interface type so it's hard for us to work w/ the objects when we need to check for certain interfaces ourselves. From: ironpython-users-bounces+dinov=microsoft....@python.org [mailto:ironpython-users-bounces+dinov=microsoft....@python.org] On Behalf Of Muyal,Tsahi Sent: Tuesday, October 11, 2011 9:13 AM To: ironpython-users@python.org Subject: [Ironpython-users] .NET Remoting and Interface based objects Hi, I am trying to call our .NET service via remoting using IronPython I have the transparent proxy object but I don't know how to cast it to the interfaces (that are implemented by the server side object) I tried IServerInterface.SomeMethod(transparent-proxy-object) but it is failing with "expected IServerInterface, got MarshalByRefObject" How can I cast it to an interface? I am using 2.7 Thanks in advance, Tsahi Muyal
_______________________________________________ Ironpython-users mailing list Ironpython-users@python.org http://mail.python.org/mailman/listinfo/ironpython-users