Solved

.NET Custom Configuration Section

Posted on 2010-11-11
5
1,181 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:Alfred1
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:Alfred1
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:Alfred1
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
 

Author Closing Comment

by:epicdevelopers
ID: 34179044
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now