473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ConfigurationPropertyAttribute.IsRequired Property

I was creating a Custom Configuration section in my web.config.

I noticed that if I set a property like:
[ConfigurationProperty("EmailAuthorizationFailures" , IsRequired = true)]

<MySection
EmailAuthorizationFailures="true"
/>
and I neglected to put the entire MySection in the web.config. I don't get
an error. Additionally if I actually read the section using
GetConfig("MySection") it comes back full of values (DefaultValue or
ValueType defaults ). I thought it would be NULL.

I would like to throw an exception if the user forgets to put in the
section in the web.config.
Is their a way to test for the missing section?

thanks,
Aug 20 '07 #1
3 1844
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><sectionelement 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/subscripti...ult.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/subscripti...t/default.aspx.

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

Aug 21 '07 #2
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><sectionelement 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/subscripti...ult.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/subscripti...t/default.aspx.

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

Aug 21 '07 #3
Thanks for your reply Chuck,

Yes, the method you mentioned should be a good trick to help perform such
detection. Thanks for sharing it with us.

BTW, I also think this is a reasonable feature and recommend you submit it
to our product feedback site:

https://connect.microsoft.com/feedba...&wa=wsignin1.0

Thanks for your posting!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Aug 22 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Johnny M | last post by:
using Access 2003 Pardon the subject line, but I don't have a better word for this strange behavior (or behavior I don't understand!!!) I have a class module named DepreciationFactor. One of...
2
by: Edward Diener | last post by:
How does one specify in a component that a property is a pointer to another component ? How is this different from a property that is actually an embedded component ? Finally how is one notified in...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
15
by: Sam Kong | last post by:
Hello! I got recently intrigued with JavaScript's prototype-based object-orientation. However, I still don't understand the mechanism clearly. What's the difference between the following...
15
by: Lauren Wilson | last post by:
Owning your ideas: An essential tool for freedom By Daniel Son Thinking about going into business? Have an idea that you think will change the world? What if you were told that there was no way...
0
by: Memfis | last post by:
While I was looking through the group's archives I came across a discussion on doing properties (as known from Delphi/C#/etc) in C++. It inspired me to do some experimenting. Here's what I came up...
10
by: shapper | last post by:
Hello, I have a custom control under namespace MyNameSpace.WebControls with a property of type validation: ' Validation Private _Validation As Validation < _ Bindable(True), _...
2
by: Dinsdale | last post by:
We have created a object library that implements the INotifyPropertyChanged.PropertyChanged to bubble changes up to higher level classes. For instance, we have a person class that can have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.