views:

576

answers:

2

Is it possible to pass a delegate to a WCF remote object from the client and have the remote object execute the delegate?

I would guess not since a delgate is a function pointer for the client process.

My goal is to have an interface structure that I can "subscribe" to events from a client to the interface. I would pass a delgate from the client to the interface and I want the interface to be able to execute the event.

The idea is to have the ability for the interface to be loaded either the assembly or remotly and have the code work the same.

If I can't pass the delegate how can I implement an event structure?

+5  A: 

not a "delegate" in C# per se, but in WCF you have duplex bindings to enable call back from the service side to the client side

http://msdn.microsoft.com/en-us/library/system.servicemodel.wsdualhttpbinding.aspx

+2  A: 

I doubt you could come up with a cohesive way to pass a delegate from a C# client to a Java service implementation and have it properly executed......

WCF is not a strict .NET implementation and thus has to deal with interop issues. It cannot rely on the assumption that both ends of the conversation are in .NET - that's why you shouldn't throw around custom exceptions between server and client either (exceptions are a .NET construct) - you need to use SOAP faults instead (which are interoperable).

So I don't think what you want to do can be done with a delegate - you'll have to come up with another way to achieve your goal.

Marc

marc_s