Solved

.NET Custom Configuration Section

Posted on 2010-11-11
5
1,172 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

9 Experts available now in Live!

Get 1:1 Help Now