Here\'s a standard scenario:
if(string.IsNullOrEmpty(Configuration.AppSettings[\"foobar\"]))
throw new SomeStandardException(\"Application not configured
The ConfigurationElement class (which is the base class of many config-related classes, like ConfigurationSection) has a method called OnRequiredPropertyNotFound (there are other helper methods too). You can maybe call those.
The OnRequiredPropertyNotFound is implemented like this:
protected virtual object OnRequiredPropertyNotFound(string name) {
throw new ConfigurationErrorsException(SR.GetString("Config_base_required_attribute_missing", new object[] { name }), this.PropertyFileName(name), this.PropertyLineNumber(name)); }