scayze
10/27/2004 6:50:00 PM
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