WCF Bindings -


Therefore, I have a WCF service that is listening to both net.tcp and net.pipe. I have created a WCF proxy client, and I want to be able to connect it via TCP or named pipes. I do not want to configure in app.config, but in the code

The WCF client will receive an endpoint address at runtime, so "net.tcp: // mymachine: 10001 / MyService" or "net.pipe: // localhost / myseva" I would think it's the right user Based on the scheme, the right net will use TCP binding or NetNamedPipBinding - but it does not appear.

Can not I just set up a proxy to take the designated pipe or TCP binding, and choose one based on this endpoint address?

EDIT: OK, so I smell the plan and divide the binding:

  var uri = new URI ("net.tcp: // localhost: 10001 / MyService "); Binding B; If (uri.Scheme == Uri.UriSchemeNetPipe) {b = New NetNamedPipeBinding (); } And if (uri.Scheme == Uri.UriSchemeNetTcp) {b = new NetTcpBinding (); } And if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) {B = new WSHttpBinding (); } Var Proxy = New Client Proxy (B, New Endpoint Address (Yuri));  

But I get a connection failure - "Communications object, system. Service module. Channel service channel can not be used for communication because it is in a defective state . "

If the compulsive binding is bound, and use NamedPipeTransportBindingElement, TcpTransportBindingElement, etc. with custom pinning ... but I'm not sure what the difference is.

/ div>

No, you can not be binding only one transport element, from one He does not understand when he is high.

You have to look at this plan, and then choose the right binding, based on that. It is quite easy, using Uri class, which will parsing for you.


Comments