I'm starting to consider creating a class library that I want to make generic so others can use it. While planning it out, I came to thinking about the various configuration settings that I would need. Since the idea is to make it open/shared, I wanted to make things as easy on the end user as possible. What's the best way to setup configuration settings without making use of web.config/app.config?
An application can execute without a web. config file, however, you cannot debug an application without a web. config file.
Locate the web. config file in the root directory of your application (or create one if it does not already exist). Add an <appSettings> element. Add <add> child elements along with key / value pairs to the <appSettings> element as required.
Web. config files may contain sensitive data. To better protect this data and strengthen the security of SharePoint, SharePoint now restricts access to its Web.
Yes you can have two web. config files in application.
Why are you rejecting the use of web.config/app.config? That's what they're for, and that's totally the way I'd do it.
Put an example block of code for the web.config/app.config in your documantation that could be copy-and-pasted into the real config file. If documented well, it shouldn't really be a problem for your users.
Just be sure you don't crash because the settings don't exist. Or, if you do crash, give a detailed error message telling the user to edit the proper config file and where in the documentation they can find examples. That would make it easier on your user.
I think it's not wrong to use the web.config for storing you configuration items. But you could be more flexible offering 3 configuration options as many popular libraries do (nhibernate, log4net, etc)
Doing it like this you leave the decision on your library users instead of supposing they won't be happy using the web.config.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With