?
Solved

.NET Custom Configuration Section

Posted on 2010-11-11
5
Medium Priority
?
1,244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 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