How does the client-side (Proxy) object register with an event to be fired on the server-side?

I would like to create a class where the client side (proxy) of the object being created can register for an event (or delegate) and receive information when that event is fired on the server side.

I tried directly, but I got SecurityException

it saying that it System.DelegateSerializationHolder

could not be serialized at this security level.

Is there a way to get around this?

Example:

MyClass proxy = Activator.GetObject(typeof(MyClass ), uri) as MyClass;
proxy.OnMyEvent += new MyEventHandler(this.Callback);

      

+1


a source to share


2 answers


No. Not anyway.

Your choice will be to either return the client to the server and register a port with it for out-of-band controls from the server. This can open up all sorts of security issues.



Probably the best way would be to force the client to poll the server to see if any events need to be processed. This leaves control over requests for information in the client's domain, and how Microsoft Exchange and other products I've worked with tend to handle this scenario.

+1


a source


Yes, it is possible, but it is disabled by default.

The default deserialization layer is .net Remoting Low

, which does not allow delegates to be passed across the Remoting boundary. You can create your own BinaryServerFormatterSinkProvider with a deserialization layer Full

and pass this provider to your channel (server side).



Here's a VB.NET example; see MSDN article on Automatic Deserialization in .NET Framework Remoting for a C # example.

Dim myChannel = New TcpServerChannel("", myPort, _
                                     New BinaryServerFormatterSinkProvider() With {.TypeFilterLevel = Runtime.Serialization.Formatters.TypeFilterLevel.Full})

      

0


a source







All Articles