c# - ActionNotSupportedException occurred after change EndpointAddress -
i working wcf , silverlight. want change endpointaddress code behind dynamically:
endpointaddress endpointadress = new endpointaddress(serviceurl); var proxy = new serverconnectionclient(context); proxy.endpoint.address = endpointadress;   connection opened successful after call method service occurred actionnotsupportedexception.
web.config:
<configuration>   <system.servicemodel>     <bindings>       <custombinding>         <binding name="nettcpbinding">           <binarymessageencoding />           <tcptransport maxreceivedmessagesize="2147483647" maxbuffersize="2147483647" />         </binding>       </custombinding>     </bindings>     <client>       <endpoint address="net.tcp://myipaddress:4502/engine/net" binding="custombinding"         bindingconfiguration="nettcpbinding" contract="ctmsconnection.iserverconnection"         name="nettcpbinding" />     </client>   </system.servicemodel> </configuration>   above config generated after add service reference.
where problem?
that easy. you have generate code same web.config.
you must use below code:
        system.servicemodel.endpointaddress endpointaddress = new system.servicemodel.endpointaddress("net.tcp://youripaddress:4502/ctmsengine/net");          system.servicemodel.channels.custombinding custombinding = new system.servicemodel.channels.custombinding();          system.servicemodel.channels.binarymessageencodingbindingelement bmeelement = new system.servicemodel.channels.binarymessageencodingbindingelement();         system.servicemodel.channels.tcptransportbindingelement tcptelement = new system.servicemodel.channels.tcptransportbindingelement();         custombinding.elements.add(bmeelement);         custombinding.elements.add(tcptelement);         tcptelement.maxreceivedmessagesize = 2147483647;         tcptelement.maxbuffersize = 2147483647;          proxy = new serverconnectionclient(custombinding, endpointaddress);      
Comments
Post a Comment