I have a class for remoting which contains events. But when I am trying to set handler for those events on the client side I receive exception. My code looks like:
//In common library
class RemoteClass : MarshalByRefObject
{
public event EventHandler SomeEvent = null;
public void SomeMethod () {}
}
//On client-side
RemoteClass r = (RemoteClass) RemotingServer.Connect (typeof(RemoteClass), "myURL");
r.SomeMethod (); //Everything is OK here.
r.SomeEvent += delegate (object o, EventArgs e) { }; //Exception:Type
System.DelegateSerializationHolder and the types derived from it (such as System.DelegateSerializationHolder) are not permitted to be deserialized at this security level.
What do I do wrong?
https://web.archive.org/web/20141009214120/http://msdn.microsoft.com/en-us/library/61w7kz4b(v=vs.80).aspx
If you’re in ASP.Net, here’s how to set the security (trust) level:
http://msdn.microsoft.com/en-us/library/ff648344.aspx