events of a remoted object

D

Dan

I am having a problem trying to assign event handlers to the events of
a remoted object. I have one program that registers the object for
remoting, Another that connects and calls methods on the object and a
third that connects to the object and waits for events. The error
occurs when I try to assign event handlers to the remoted object's
events in the third program (Listener).

hubListenerConnection.ContextRequest += new
Hub.ContextRequestEventHandler(hubListenerConnection_ContextRequest);

This line throws a System.Security.SecurityException

Additional information: Type System.DelegateSerializationHolder and
the types derived from it (such as System.DelegateSerializationHolder)
are not permitted to be deserialized at this security level.

The Hub (inherits MarshalByRefObject) object events are declared as
follows:

public delegate void ContextRequestEventHandler(object sender,
EventArgs.ContextRequestEventArgs e);

public event ContextRequestEventHandler ContextRequest;

protected virtual void
OnContextRequest(EventArgs.ContextRequestEventArgs e)
{
if (ContextRequest != null)
{
ContextRequest(this, e);
}
}

The custom EventArgs are declared with [Serializable] as is the
listener.

Any help with what I am doing wrong to get this error and what I can
do to make this system work?

Thanks,
Dan
 
N

Nicholas Paldino [.NET/C# MVP]

Dan,

Check out the article on CodeProject.com titled ".NET Remoting: Passing
through the obstacles path from version 1.0 to 1.1", which details how to
deal with this issue (it consists mainly of setting the type filter level on
the client and server). It is located at (watch for line wrap):

http://www.codeproject.com/csharp/PathRemotingArticle.asp

Hope this helps.
 
D

Dan

Thank you Nicholas, that example was very helpful. I now have the
system up and working. Though the event repeater being created by the
client and then remoted to the server works, the whole system would be
so much cleaner if the clients could subscribe to events of the server
object directly. Does anyone know if this will change with whidbey?

-Dan

Nicholas Paldino said:
Dan,

Check out the article on CodeProject.com titled ".NET Remoting: Passing
through the obstacles path from version 1.0 to 1.1", which details how to
deal with this issue (it consists mainly of setting the type filter level on
the client and server). It is located at (watch for line wrap):

http://www.codeproject.com/csharp/PathRemotingArticle.asp

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Dan said:
I am having a problem trying to assign event handlers to the events of
a remoted object. I have one program that registers the object for
remoting, Another that connects and calls methods on the object and a
third that connects to the object and waits for events. The error
occurs when I try to assign event handlers to the remoted object's
events in the third program (Listener).

hubListenerConnection.ContextRequest += new
Hub.ContextRequestEventHandler(hubListenerConnection_ContextRequest);

This line throws a System.Security.SecurityException

Additional information: Type System.DelegateSerializationHolder and
the types derived from it (such as System.DelegateSerializationHolder)
are not permitted to be deserialized at this security level.

The Hub (inherits MarshalByRefObject) object events are declared as
follows:

public delegate void ContextRequestEventHandler(object sender,
EventArgs.ContextRequestEventArgs e);

public event ContextRequestEventHandler ContextRequest;

protected virtual void
OnContextRequest(EventArgs.ContextRequestEventArgs e)
{
if (ContextRequest != null)
{
ContextRequest(this, e);
}
}

The custom EventArgs are declared with [Serializable] as is the
listener.

Any help with what I am doing wrong to get this error and what I can
do to make this system work?

Thanks,
Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top