- People says that libraries shouldn't have configuration files.
- I can't pass arguments to my WCF service class from its host (but I can from the client).
- I don't want to store the configuration on the client.
- What should I do?
views:
156answers:
2What are you asking? Are you talking about settings for the service (the server side), or the client?
Why can't you just use client-side config files like you do for other apps? This is the built-in, preferred way of doing things - why insist on not using it??
So again: what is it really that you're asking? Or what problem is it, that you're trying to solve, really?
for a service (server-side): store your bindings, behaviors, service endpoints etc. in the web.config (if hosting in IIS) or in the app.config of your service host (if NT Service or console app)
for a client: store your configuration in the main app's app.config that uses your library. If you want to, you can provide ready-made "client.config" and "bindings.config" files and then just simply add
<system.serviceModel> <bindings configSource="bindings.config" /> <client configSource="client.config" /> </system.serviceModel>
to your client app's app.config - doesn't get much easier than that, really!
I don't if i'm approaching this question properly...
The first point is totally arbitary, and sounds a bit fascist, or bolshie if you come from the Uk. Many different types of libraries come with configuration file. What other way would you do it? How would it work if you didn't have configure it, which is what .NET configuration model is built on.
Folk need to stop focusing on architecture buffs, P&P mechanics and programming purists, who often take extreme views based on some best, or minor design principles, above all else saying you should do this and do that.
On a purley technical footing, if your wanting to hide your configuration file, encrypt them. If you don't want to do that, but want them exposed to authorized users, then use protected storage.
Bob.