RE: ConfigurationPropertyAttribute.IsRequired Property



Thanks,
I'll think I will use a little hack.
Create a setting. IhaveBeenSpecified default =false.
When I read the settings in code if it is false, I'll throw an exception.


"Steven Cheng[MSFT]" wrote:

Hi Chuck,

As for the "how to test the missing of a configuration section in .net
config file", I think it a good question. However, based on my research,
the current .NET configuration settings model doesn't provide support of
detecting the existence of a configuration section automatically(only the
detection of a sub section properrty is supported). This limitation is due
to the following design of the configuration section processing mechanism:

** When .net application runs, it will not always load all the
configuration settings at one time or at the startup time. The loading of
each configuration section is on-demand and may occur at different time.
Thus, it won't be convenient to check all the potential configsection's
existence.

** So far <configSections><section> element only support the definition of
the scope and modify-behavior of the registered section, haven't provided
setting to control the existence detection

For your scenario, if you do need to take care of some certain custom
configuration's existence, I think you may consider manually use the
configuration API to query the certain section in code or use XML API to
perform xml query against the app.config file.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.






.



Relevant Pages

  • Re: ChangePicture shape dynamically and Keep its Format/Properties
    ... your existing picture will appear with a new name (something like ... this method cannot capture all the settings of the original ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.office.developer.automation)
  • Re: user.config file in .net version 1.1
    ... the appSettings element specifies a configuration file that provides ... additional settings or overrides the settings that are specified in the ... application-scoped settings and user-scoped settings. ... Microsoft Online Community Support ...
    (microsoft.public.vsnet.ide)
  • RE: VB 2005 and Content Security Question
    ... must the sensitive data be stored in SQL Server database ... if you have some sensitive configuration setting that need to ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.vb)
  • RE: VS 2005 DB Pro Edition, PostDeploy problem
    ... solution configuration? ... Dim solutionBuild As EnvDTE.SolutionBuild ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.ide)
  • RE: How to tell if web.config item is/is not inherited
    ... noticed that appSettings and connectionStrings in the Configuration object ... contain both settings inherited from parent web.config and settings in ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)