0

What's the best practice in a desktop application for configuring WCF services to connect do different endpoints depending on whether your in a development environment, system testing environment, production, etc...? When I did web application development connecting to DBs, I modified the web.config to have different connection strings based on vertical. Is it the same approach with WCF endpoints and just update the app.config file?

Thanks!

znkgn
  • 3
  • 1

1 Answers1

0

Use configuration file transformation: https://msdn.microsoft.com/en-us/library/dd465318(v=vs.100).aspx

For example:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
   <system.serviceModel>
      <client>
         <endpoint name="BasicHttpBinding_IService" address="NEW_ADDRESS"
           xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
      </client>
   </system.serviceModel>
</configuration>
GôTô
  • 7,974
  • 3
  • 32
  • 43
  • This appears to only be supported for web.config, but not app.config for desktop apps. Googling appears to reveal a few ways where you can kind of hack a solution together. Does VS not have a supported way of achieving different configs for different environments? – znkgn Feb 17 '17 at 15:20
  • http://gunnarpeipman.com/2013/11/using-web-config-transforms-with-app-config-files/ – GôTô Feb 17 '17 at 15:23
  • Yeah, that's one of the articles I found as well. He mentions right in there that it's hacking together a solution. I guess consensus is that Visual Studio doesn't support transformations for app.config? – znkgn Feb 17 '17 at 16:01