How can my .Net app determine whether to use app.config or web.config

Posted by sipwiz on Stack Overflow See other posts from Stack Overflow or by sipwiz
Published on 2010-06-06T12:36:15Z Indexed on 2010/06/06 12:42 UTC
Read the original article Hit count: 515

Filed under:
|
|

I have a class that needs to get some settings from the application configuration file and that is used in a console based app and a web app.

Other than catching an exception how can I determine whether to use:

ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None));

or

ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(WebConfigurationManager.OpenWebConfiguration("~"));

© Stack Overflow or respective owner

Related posts about .NET

Related posts about web-config