none
How can I write end point programmatically (netPeerTcpBinding) RRS feed

  • Question

  • Hi I need to write this end proint programatically in c# , this is for a chat application .//app.config part

     <system.serviceModel>
            <client>
              <endpoint name="ChatEndPoint" address="net.p2p://chatMesh/ChatServer" binding="netPeerTcpBinding" bindingConfiguration="PeerTcpConfig" contract="Clinical_Vista.IChatService"></endpoint>
    
    
            </client>
    
            <bindings>
              <netPeerTcpBinding>
                <binding name="PeerTcpConfig" port="0">
                  <security mode="None"></security>
                  <resolver mode="Custom">
                    <custom address="net.tcp://192.168.0.147:22222/ChatServer" binding="netTcpBinding" bindingConfiguration="TcpConfig"></custom>
                  </resolver>
                </binding>
                <!--<binding name="BindingDefault" port="0">
                  <security mode="None"></security>
                  <resolver mode="Auto"></resolver>
                </binding>-->
              </netPeerTcpBinding>
              <netTcpBinding>
                <binding name="TcpConfig">
                  <security mode="None"></security>
                </binding>
              </netTcpBinding>
            </bindings>
          </system.serviceModel>

    // c# part

     InstanceContext context = new InstanceContext(
                            new Home(txtUserName.Text.Trim()));
                        factory =
                            new DuplexChannelFactory<IChatChannel>(context, "ChatEndPoint");
                        channel = factory.CreateChannel();

    This is working fine for me . but I need to change the end point address dynamically. Looking for valuable support

    Monday, February 15, 2016 6:21 AM

Answers

All replies

  • Hi I need to write this end proint programatically in c# , this is for a chat application .//app.config part

     <system.serviceModel>
            <client>
              <endpoint name="ChatEndPoint" address="net.p2p://chatMesh/ChatServer" binding="netPeerTcpBinding" bindingConfiguration="PeerTcpConfig" contract="Clinical_Vista.IChatService"></endpoint>
    
    
            </client>
    
            <bindings>
              <netPeerTcpBinding>
                <binding name="PeerTcpConfig" port="0">
                  <security mode="None"></security>
                  <resolver mode="Custom">
                    <custom address="net.tcp://192.168.0.147:22222/ChatServer" binding="netTcpBinding" bindingConfiguration="TcpConfig"></custom>
                  </resolver>
                </binding>
                <!--<binding name="BindingDefault" port="0">
                  <security mode="None"></security>
                  <resolver mode="Auto"></resolver>
                </binding>-->
              </netPeerTcpBinding>
              <netTcpBinding>
                <binding name="TcpConfig">
                  <security mode="None"></security>
                </binding>
              </netTcpBinding>
            </bindings>
          </system.serviceModel>

    // c# part

     InstanceContext context = new InstanceContext(
                            new Home(txtUserName.Text.Trim()));
                        factory =
                            new DuplexChannelFactory<IChatChannel>(context, "ChatEndPoint");
                        channel = factory.CreateChannel();

    This is working fine for me . but I need to change the end point address dynamically. Looking for valuable support

    Simply need  to write the app.config part in c#. 
    • Edited by JPVVTNKL Monday, February 15, 2016 6:23 AM
    Monday, February 15, 2016 6:23 AM
  • Hello,

    In WCF, if we want to write the endpoint or app.config programmatically, usually we will use the ChannelFactory class, especially when the client does not use configuration files. In your case you need to use the DuplexChannelFactory<TChannel>(InstanceContext, Binding, EndpointAddress) to add the endpoint programmatically.

    Best Regards,
    Fang Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 17, 2016 8:20 AM
    Moderator