WCF Discovery finds endpoint but host is “localhost”

后端 未结 2 1810
忘掉有多难
忘掉有多难 2021-02-10 09:02

I am trying to use the Discovery feature in WCF using http://msdn.microsoft.com/en-us/library/dd456783(v=VS.100).aspx as a starting point. It works fine on my machine, but then

相关标签:
2条回答
  • 2021-02-10 09:22

    After doing some more searchingI have found no other solution than to use the System.Environment.MachineName

     new EndpointAddress(new UriBuilder {Scheme = Uri.UriSchemeNetTcp, Port = port, Host = System.Environment.MachineName}.Uri);
    
    0 讨论(0)
  • 2021-02-10 09:22

    I spent a lot of time investigating this problem. Building base addresses in the code was not acceptable for me, as it implies hardcoding transport scheme and port (the latter, of course, can be stored in a separate config section, but then why not just to use the existing section?). I wanted to have an ability to just configure the base address in config as usual. And it turns out that a base address like <add baseAddress="net.tcp://*:8731/"/> will perfectly work. I think the same is true for programmatic configuration.

    0 讨论(0)
提交回复
热议问题