all groups > dotnet remoting > april 2006 >
You're in the

dotnet remoting

group:

How to specify client to use HTTP Binary Progmatically ??


How to specify client to use HTTP Binary Progmatically ?? <Chaz>
4/30/2006 11:40:28 PM
dotnet remoting:
Ok we have .config files to specifiy the Remoting configuration, but I cant
use them as the URL and potentially the formatting mode may change based on
client requirements.

I need to pull the settings from my own configuration data and apply code at
runtime which has the same effect.

I have found out how to create and register a channel;

System.Runtime.Remoting.Channels.Http.HttpChannel mynewchannel
= new System.Runtime.Remoting.Channels.Http.HttpChannel(9402);

And to register the well known type;

System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyObj),"http://kkkkk",WellKnownObjectMode.SingleCall)

But I cant find out how to tell the client to use the Binary Formatter for
this channel ??

Is there anyone that can anyone help ?

Kindest Regards

Chaz

RE: How to specify client to use HTTP Binary Progmatically ?? KidO
5/2/2006 5:21:10 AM
The code below registers an HTTP Channel using binary.

IDictionary props = new Hashtable();
props["name"] = channelName;
props["port"] = portNumber;

BinaryServerFormatterSinkProvider serverProv = new
BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProv = new
BinaryClientFormatterSinkProvider();

HttpChannel chnl = new HttpChannel(props, clientProv, serverProv);

ChannelServices.RegisterChannel(chnl);

--
- John


[quoted text, click to view]
Re: How to specify client to use HTTP Binary Progmatically ?? <Chaz>
5/3/2006 9:49:18 PM
Superb, thanks John

Although I did find that I had to omit the portNumber or I got an error
message stating that the port can only be used once and was in use, even if
I attempted to Unregister all existing channels?

By simply specifiying and registering a Binary Formatted HttpChannel it
seems to work and does appear to be formatting as binary

Thanks again

Chaz


[quoted text, click to view]

AddThis Social Bookmark Button