User Defined config section "You must implement a default accessor onSystem.Configuration.Configurat

S

saurabh srivastava

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

Hello All,

I am having my app.config file like :


<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<configSections>
<section name="PredefinedClusters"
type="BinaryChecker.ClusterSection,BinaryChecker"/>
</configSections>

<PredefinedClusters>

<Cluster name="Portal">
<Environments>
<Env name="aa">
<Servers>
<Server name="zz"/>
<Server name="xx"/>
</Servers>
</Env>
<Env name="bb">
<Servers>
<Server name="cc"/>
<Server name="vv"/>
</Servers>
</Env>
</Environments>
<BinaryPaths>
<BinaryPath name="common" binpath="croot\"/>
</BinaryPaths>
</Cluster>
</PredefinedClusters>
</configuration>


I wanna to access this app.config file using
ConfigurationElementCollection so I created Collections:
and Successfully able to access the contents in object.

but when I serializing the object it is giving the exception.


****** XmlSerializer ser = new
XmlSerializer(configSection.GetType());-->this line throwing the
exception

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

Any Solution ***
 
P

Peter Duniho

saurabh said:
[...]
but when I serializing the object it is giving the exception.

****** XmlSerializer ser = new
XmlSerializer(configSection.GetType());-->this line throwing the
exception

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

Any Solution ***

The error message seems pretty clear to me. Implement a default accessor.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top