[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

.NET Custom Configuration Section

Posted on 2010-11-11
5
Medium Priority
?
1,257 Views
Last Modified: 2012-05-10
I created a custom configuration section using the System.Configuration.ConfigurationSection class.

I'm have created a class that extends the ConfigurationElementCollectionClass -  to represent a configuration element containing a collection of child elements.

The class works fine when retrieving values from the configuration file, but when I try to remote an object of this type, I get the following exception:

"You must implement a default accessor on
System.Configuration.ConfigurationLockCollection because it inherits
from ICollection."

In my class that extends ConfigurationElementCollection, I have the following accessor

        public ManufacturerConfigurationElement this[int index]
        {
            get
            {
                return (ManufacturerConfigurationElement)BaseGet(index);
            }
            set
            {
                if (BaseGet(index) != null)
                {
                    BaseRemoveAt(index);
                }

                BaseAdd(index, value);
            }
        }

Any ideas why I'm still receiving this exception?

Thanks,
0
Comment
Question by:epicdevelopers
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:Alfred A.
ID: 34117189
Check this out:

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_21511144.html

You need to put the "Default" keyword in your accessor.
0
 
LVL 21

Expert Comment

by:Alfred A.
ID: 34117220
Oh I didn't notice it is C#, you have already the indexer equivalent for "Default" VB.NET keyword.  Sorry.
0
 
LVL 21

Expert Comment

by:Alfred A.
ID: 34117271
Check the comments in this link.  This might help.

http://www.dotnet247.com/247reference/msgs/13/66184.aspx
0
 

Accepted Solution

by:
epicdevelopers earned 0 total points
ID: 34138931
Alfred - thanks for the reply, but that link's suggestion did not help.

As a workaround, I ended up following this article's idea:

http://www.rahulsingla.com/blog/2010/10/net-serializing-custom-configuration-sections-and-generating-documentation-for-them

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month19 days, 17 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question