Solved

.NET Custom Configuration Section

Posted on 2010-11-11
5
1,191 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

808 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