5

There are numerous resources available on WCF and configuration (both programmatic and via app.config). However, I have not seen a good resource on practical management of this configuration, particularly in a production environment.

WCF is powerful in that the framework allows configuration via the app.config file so that you can tweak various settings without having to recompile code.

When installing a WCF client, how do you easily configure the client to point to the right server? This is probably the most common thing I can think of to configure after installing. For some context, suppose I ship a product which has a server component and a client component. Customers can install both wherever. While an xml file is powerful for post-development configuration, it is not user-friendly at all. Given that there can be several dozen endpoints in a config file, does the admin or end user have to manually change all of them? I know I could do everything programmatically, but then I essentially am re-implementing all of the out-of-the-box plumbing.

Above question, more generalized is: how can I simplify WCF configuration via some basic UI without re-implementing what is provided by the framework?

Travis
  • 2,654
  • 4
  • 26
  • 46
  • 1
    if you really don't like the config files you could allways write a config-app on top of this app.config. It not hard to parse and write after all. – Random Dev Sep 12 '11 at 21:05
  • 1
    If you're on an enterprise scale - check out [SO-AWARE](http://www.tellagostudios.com/products/so-aware%E2%84%A2) – marc_s Sep 12 '11 at 21:09
  • @Carsten I think a config app is a little overkill. Tweaking low-level settings like buffer sizes etc are hopefully rare tuning things to resolve problems. Something as simple as changing the server name hosting the services, though, is far more common. – Travis Sep 13 '11 at 02:49
  • @marc_s Similar comment applies, SO-AWARE seems like even more overkill for what may be a single application. – Travis Sep 13 '11 at 02:49

3 Answers3

3

If you want user friendly installation you will use some installer where you simply set some configuration values. Check either installer project provided as part of Visual studio or more powerful (and much more complex) WiX. If you don't have installer you already chose that users are supposed to configure everything manually.

If your only problem is address of services and you plan to deploy services and clients to single LAN you can also add WS-Discovery (available in WCF 4) where clients are able to find service on the network.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Install time makes sense, though having to manually replace elements in the app.config file seems tedious and/or error prone (especially in an installer). Do you have any suggestions for how to do this, or (better) how to do it at runtime? Discovery is a good point, though not viable in my scenario (over WAN). – Travis Sep 13 '11 at 16:25
  • If you want to do it at runtime you are going to write your own configuration tool - either part of your primary application or second application shipped with the main one. I don't think that standard WCF configuration tool can be shipped with your application. – Ladislav Mrnka Sep 13 '11 at 16:30
  • I wouldn't want to ship the standard WCF configuration tool anyway -from and end-user perspective, that would be a nightmare. Essentially I just want to replace the endpoint hostnames for client configurations in the app.config file at runtime. From the sound of it there isn't a built-in way to do this. I am looking at overriding the EndpointAddress property when creating the channel - I think this is my best bet. – Travis Sep 13 '11 at 18:33
1

if you like to have/make a nice UI to edit those settings, the user input from that UI will need to be saved somewhere and you will have to use it when creating your service calls on the clients or setting up your hosted services on the server. Personally I would store in the database and will use them to configure the WCF endpoints at runtine with coded approach.

this has also some advantages, all backed up with db backup, remote connection and inspection, no risk to overwrite files on updates and so on.

If your setup/application has no database then configuration files are also ok and probably the only way, I would not save anything in the Registry anyway.

Davide Piras
  • 43,984
  • 10
  • 98
  • 147
  • My question is less about how to prompt/store settings and more about how to modify the configuration read by WCF at runtime (i.e., I've stored the settings, how to I make WCF aware). – Travis Sep 13 '11 at 16:13
0

You could use the settings framework to store the endpoint address. You can easily read and save settings and they'll be stored in the %APPDATA% location so you don't need to worry about permissions. You'd need just a small configuration UI where the user can enter the server name. Validate that configuration by adding a simple Hello service to your server and try to reach that service in that UI. So you can give the user immediate feedback if the server address is right.

The other option is to implement a discovery protocol. A related question is here.

Community
  • 1
  • 1
Andreas
  • 6,447
  • 2
  • 34
  • 46
  • My question is less about how to prompt/store settings and more about how to modify the configuration read by WCF at runtime (i.e., I've stored the settings, how to I make WCF aware). – Travis Sep 13 '11 at 16:13