471,605 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

deserialize to C# class from external config file?

I'm using System.Configuration in .NET 2.0 to load in values
from an externally specified config file and deserialize
them into a C# class. During deserialization, I'm getting
an exception thrown by .NET It's having a problem with
the <connections> element seen below. I've tried different things, but
still I can't get the deserialize to succeed. Here's the problem in
detail below.

Can anybody tell me what I'm doing wrong? Shouldn't
[xmlArray] work?


The app.config file looks like this:

<section name="dataAccessSection"
type="Framework.Data.DataAccessConfig,Framework.Da ta,Version=,
Culture=neutral, PublicKeyToken=null"/>

<dataAccessSection configSource="DataAccess.config"/>

DataAccess.config looks like this:

<connection name="fsa">
<connectionEnv envName="INT1" assembly="System.Data,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionString="Provider=OraOLEDB.Oracle;Passwor d={0};Persist Security
Info=True;User ID=fiisbsvc;Data Source=dbenv022"
connectionStringPassword="lttC8Hg29Nfks+3QPI8Hxg== ">
The C# class looks like this:

using System;
using System.Xml.Serialization;
using System.Configuration;

namespace Framework.Data
/// <summary>
/// Represents the root of all data access configuration information.
/// </summary>
public class DataAccessConfig : ConfigurationSection
#region Constructor(s)

/// <summary>
/// Initializes a new instance of the <see cref="DataAccessConfig"/>
/// </summary>
public DataAccessConfig()
_sectionName = _defaultSectionName;


#region Config Manager
private const string _defaultSectionName = "dataAccessSection";
private string _sectionName;

#region Connection Config

private ConnectionConfigCollection _connections = new

/// <summary>
/// Gets or sets the collection of connection configuration items
associated with this application.
/// </summary>
/// <value>The collection of connection configuration items associated
with this application.</value>
// [ConfigurationProperty("connections")]
// [ConfigurationCollection(typeof(ConnectionConfigCol lection))]
public ConnectionConfigCollection Connections
return _connections;
_connections = value;

Feb 22 '06 #1
0 2922

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Greg | last post: by
1 post views Thread by Alex | last post: by
2 posts views Thread by Tony Jones | last post: by
reply views Thread by John Manion via .NET 247 | last post: by
5 posts views Thread by Rainer Queck | last post: by
4 posts views Thread by Chris Marsh | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.