Deserialization exception when using MarshalByRef object with events

From: Shannon Cayze (scayze_at_us.loreal.com)
Date: 10/27/04


Date: 27 Oct 2004 11:50:14 -0700

Hello all,

I'm getting the following exception on the client when attempting to
assign a delegate to a MarshalByRefObject's event on the server:

"An unhandled exception of type 'System.Security.SecurityException'
occurred in mscorlib.dll

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."

I saw all sorts of documentation telling me to change the
typeFilterLevel to full, either in a .config file or in code. I've
tried it both ways and it still doesn't work. Here are the key parts
of code from the server, client, MarshalByRef object, and .config
files:

***************** Server code **************************

public class Server
{
  .
  .
  public void Start()
  {
    RemotingConfiguration.Configure("Server.exe.config");
  }
  .
  .
}

***************** Client code **************************

public class Client
{
  .
  .
  public void Start()
  {
    RemotingConfiguration.Configure("Client.exe.config");
    Bomb bomb = new Bomb();
    bomb.BombDetonated += new BombHandler(BombDetonated);
    bomb.Detonate();
  }

  private void BombDetonated(Bomb bomb)
  {
    Console.WriteLine("Bomb Detonated");
  }
  .
  .
}

***************** MarshalByRefObject code **************************

public class Bomb : MarshalByRefObject
{
  public delegate void BombHandler(Bomb bomb);
  public event BombHandler BombDetonated;
  public event BombHandler BombDiffused;

  public void Detonate() {...}
  public void Diffuse() {...}
}

***************** Server.exe.config **************************

<configuration>
  <system.runtime.remoting>
    <application>
      <channels>
        <channel ref="Tcp" port="4000" />
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full" />
          </serverProviders>
      </channels>

      <service>
        <wellknown mode="Singleton" type="SharedObjects.Bomb,
SharedObjects"
             objectUri="Bomb.rem" />
      </service>
    </application>
  </system.runtime.remoting>
</configuration>

***************** Client.exe.config **************************

<configuration>
  <system.runtime.remoting>
    <application>

      <channels>
        <channel ref="tcp" port="0">
          <clientProviders>
            <formatter ref="binary" />
          </clientProviders>
          <serverProviders>
            <formatter ref="binary" typeFilterLevel="Full" />
          </serverProviders>
        </channel>
      </channels>

      <client>
        <wellknown type="SharedObjects.Bomb, SharedObjects"
url="Tcp://localhost:4000/Bomb.rem" />
      </client>

    </application>
  </system.runtime.remoting>
</configuration>

*********************************************************

Also, if I start the program without debugging, part of the exception
refers to the Microsoft .Net security policy and altering it. Can
anyone tell me what I'm doing wrong? I've seen many threads where
people have gotten it to work, so I know it's possible, but I think
I'm missing something small.

Thanks in advance,
Shannon



Relevant Pages

  • Re: Socket problems
    ... I'm trying to write a 20 client chat server which is not ... >> public void listenFromClients() ... > // create a new communicator task and pass it the socket ...
    (comp.lang.java.programmer)
  • Remoting Error
    ... can the server application call methods of the shared Object?? ... public RemDeskBridge rdb; ... The procedure on client side is:- ... public void setUP ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Multiplayer gaming
    ... Server code: ... public void RunServer() { ... Client client = new Client); ... We have a very simple game with several spaceships which try to kill ...
    (microsoft.public.dotnet.csharp.general)
  • Re: GSSException: Failure unspecified at GSS-API level (Mechanismbytes long)
    ... This problem only occurs when the server is being run using java 1.5 ... and I connect from a client using java 1.4 or vice versa. ... I created a special SecurityContext class which both the ... public void setServiceName{ ...
    (comp.protocols.kerberos)
  • Re: How can server interrupt client in browser?
    ... The rationale here is not to use up a TCP/IP connection and a server ... private static MessageThread socketThread; ... public void shutdown() ... the browser client is single threaded. ...
    (comp.lang.javascript)