Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pros and Cons of wcf config file vs in code config

I have a self hosted C# WCF service which creates 20+ endpoints for various purposes. Each is configured in the code itself with a few basic config items in the app.config of the service such as port and address. The service works great for the tested clients, but has not been widely tested.

I was a little leary of the standard wcf config file approach because I was afraid the end user would mess things up and hence did everything in code.

Is it a better idea to do the configuration in the config file because then the end user could customize it to their needs or is the in code approach sufficient for most needs?

like image 893
Telavian Avatar asked Apr 26 '12 16:04

Telavian


1 Answers

You need to ask yourself some questions

  • do different developers have different values on their machine?
  • will someone else that does not work with the c# have to change these setting values? (e.g. an admin)
  • Will certain values (e.g. message size) need to be adjusted for performance later on?

If the answer is yes to any of those questions then you need to move the settings into a .config file. If your worry is that clients who understand other settings are going to mess up your wcf settings on accident you can always separate settings by adding the configSource attribute to your web.config or app.config file for each tag and put parts of your configuration in separate files in a sub-directory to reduce the likelihood of an accidental change.

like image 196
Charles Lambert Avatar answered Oct 05 '22 10:10

Charles Lambert