by StoneJunction
5. February 2010 03:44
Working on some remoting communications I came across a security problem when serializing an object to send to the server from the client.
The error was of the form : "Because of security restrictions, the type <class name to be serialised> cannot be accessed."
The problem turned out to be that custom type serialization was turned off by default which can be set in code on the server:
var provider = new BinaryServerFormatterSinkProvider {TypeFilterLevel = TypeFilterLevel.Full};
var props = new Hashtable {{"port", 20001}};
var chl = new TcpServerChannel(props, provider);
or it can be set in the app.config under the channel element with :
<serverProviders>
<formatter ref="binary" typeFilterLevel="Full"/>
</serverProviders>