2

WCF service is hosted in IIS and uses netTCPRelayBinding.

At some locations the TCP ports are blocked and HTTP must be used. Other times TCP ports are open and this mode is preferred.

Thus, I'd like to be able to set the ConnectivityMode to AutoDetect (or to just HTTP) declaratively in the web.config file.

For self hosted WCF, this is easily done:

ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect;

How is this done declaratively in web.config?

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
VR Coder
  • 21
  • 2

1 Answers1

0

At the moment there is no configuration element for this setting however in your web.config you could use AppSettings to set the value

<appSettings>
   <add key="ServiceBusConnectivityMode" value="Http" />
</appSettings>

In the code you would then read the key value and parse it into enum value

ServiceBusEnvironment.SystemConnectivity.Mode = (ConnectivityMode)Enum.Parse(typeof(ConnectivityMode), ConfigurationManager.AppSettings["ServiceBusConnectivityMode"])
Alex S
  • 1,171
  • 1
  • 9
  • 25