473,323 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 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?

Thx,
Tom

The app.config file looks like this:

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

<dataAccessSection configSource="DataAccess.config"/>
</configuation>

DataAccess.config looks like this:

<dataAccessSection>
<connections>
<connection name="fsa">
<connectionEnvs>
<connectionEnv envName="INT1" assembly="System.Data,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
type="System.Data.OleDb.OleDbConnection"
connectionString="Provider=OraOLEDB.Oracle;Passwor d={0};Persist Security
Info=True;User ID=fiisbsvc;Data Source=dbenv022"
connectionStringPassword="lttC8Hg29Nfks+3QPI8Hxg== ">
</connectionEnv>
</connectionEnvs>
</connection>
</connections>
<commands/>
<maps/>
</dataAccessSection>
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"/>
class.
/// </summary>
public DataAccessConfig()
{
_sectionName = _defaultSectionName;
}

#endregion

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

#region Connection Config

private ConnectionConfigCollection _connections = new
ConnectionConfigCollection();

/// <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>
[XmlArray("connections")]
[XmlArrayItem("connection")]
// [ConfigurationProperty("connections")]
// [ConfigurationCollection(typeof(ConnectionConfigCol lection))]
public ConnectionConfigCollection Connections
{
get
{
return _connections;
}
set
{
_connections = value;
}
}
..
..
..
}

Feb 22 '06 #1
0 2997

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Greg | last post by:
I'm writing a class in C# .... I have a collection calls Reports made up of Report objects. I'm trying to deserialize an XML file that looks like : <Reports> <Report> <Title>some title</Title>...
1
by: Alex | last post by:
I am creating an application that allows the user to link a plug-in "utility" class (Watcher) to a class at runtime. There are several Watcher utilities, each with a different style of "watching"...
2
by: Tony Jones | last post by:
Is it possible for me to create a class library DLL and have it read it's configuration settings from the web.config of the ASP.NET application referencing it? IE - if I call...
0
by: John Manion via .NET 247 | last post by:
Long Post, thanks for your patience... I have and XML file that looks something like this: <?xml version="1.0" encoding="utf-8" ?> <Settings> <Location> <X>30</X> <Y>40</Y> </Location>...
2
by: Magnus | last post by:
I'm currently developing an application with classified information as input to a couple of algorithms. Which strategy should I use to protect the input data from beeing read? The files should...
5
by: Stimp | last post by:
I've created a dll that I placed in my web application's 'bin' directory. I want to access the web.config file from this dll so that I can retrieve a node value. e.g. Dim oDoc As...
5
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The...
4
by: Chris Marsh | last post by:
All Good day to everyone! I am developing a system which interfaces with various external systems. The set of external systems will change and grow over time. I will produce a new class to...
4
by: ink | last post by:
Hi All I am relatively new to doing this and i think that i am making some king of school boy error. The error i am getting is on the following line of code. XmlSerializer xs = new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.