Static News Archive



   (28-Apr-08 0:02)  A few solutions to some .net remoting problems
I've been struggling through a few .net remoting problems over the last few days. Here are a couple of problems I've come across, and found solutions to:


Error: "System.ArgumentNullException: No message was deserialized prior to calling the DispatchChannelSink. Parameter name: requestMsg"

Happens when you have two channels in one application registering seperately - one as a client, one as a server.
If they both use the same SinkFormatter (i.e. BinaryServerFormatterSinkProvider) then calling a method on a remote object from the application will throw this exception.

Fix:

Register both the client and server at the same time:


BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;

IDictionary props = new Hashtable();
props["port"] = m_serverPort;

//Specify both a client AND server provider - the client one can just be created inside the channel constructor:
m_channel = new HttpChannel(props, new BinaryClientFormatterSinkProvider(), provider);
ChannelServices.RegisterChannel(m_channel, false);





Error: "Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed."
Happens when trying to fire events from the server back to the client.

A lot of information on the internet puts this down to a deficiency in .net 1.1, but if you are using .net 2.0 or above, your problem may be something different than the following solution:


Fix (for .net 1.1 issues):

When registering a client channel, you must explictly set the typeFilterLevel in the props hashtable:



//Setting this here apparently does something different than setting it on the serverProvider...
IDictionary props = new Hashtable();
props["port"] = m_serverPort;
props["typeFilterLevel"] = "Full";

m_channel = new HttpChannel(props, new BinaryClientFormatterSinkProvider(), null);
ChannelServices.RegisterChannel(m_channel, false);



Fix (for .net 2.0 issues)

Instead of just creating a BinaryClientFormatterSinkProvider for the client channel, also pass a BinaryServerFormatterSinkProvider channel and specify its type filter level to Full:


BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;

IDictionary props = new Hashtable();
//props["name"] = string.Empty;
props["port"] = m_serverPort;
props["typeFilterLevel"] = "Full";

m_channel = new HttpChannel(props, new BinaryClientFormatterSinkProvider(), provider);


I hope this helps someone get through these exceptions faster than I got through them!

Post a comment     
(30-May-13 9:48)  Posted by Niko78
Thank you !!! I have this problem when running remoting objests in diferents AppDomain. You code snipet work perfectly !!

<-  (21-Apr-08 23:37)  Simple Js problem an... (16-May-08 20:44)  Multiple remoting cl...  ->













(sitemap)