• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Read Specialized Config File

I am trying to get some data out of a config file and I am not sure how.  Here is the file:

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

    <section name="DatabaseInformation" type="eFoundation.Server.CeFnCfgDatabaseHandler, eFoundation.Server" />
    <section name="Messages" type="eFoundation.Shared.CeFnCfgMessageHandler, eFoundation.Shared" />
    <section name="Remoting" type="eFoundation.Shared.CeFnCfgRemotingHandler, eFoundation.Shared" />
    <add key="siteRoot" value="/" />
    <add key="imageRoot" value="/Images/" />
      <connection id="Reader" dataProvider="SqlConnection">
      <connection id="Writer" dataProvider="SqlConnection">

My question is how do I get the two connection strings?

Thanks much.
  • 4
  • 2
1 Solution
Where did you get the config from? it seems some else has written a parser to do extract out the "DatabaseInformation" config settings, why don't you use it?
ten_spoonsAuthor Commented:
The config file was created by a consultant we used a while back.  The problem is the parsing class he created to access the Database information is all in a DLL and I can not access it.  So, I need to recreate this parser, I am just not sure how to go about it.
Some tutorials to get you started.

Creating Custom Configuration Settings in ASP.NET

Using Application Configuration Files in .NET

Creating a Flexible Configuration Section Handler

HOW TO: Create a Custom ASP.NET Configuration Section Handler in Visual Basic .NET

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

ten_spoonsAuthor Commented:
I realize how to create a custom section handler and how to read from it.  The problem I am having is the handler for this particular sections creates a private class that I can not access.

When I try to GetConfig of this particular section it returns an object of type CeFnCfgDatabaseItem.  This class is private and therefore I can not use it, and can not even see the code behind it because it is in a DLL.  Is there anyway I can possibly convert this to a different class?

Thanks much.
Only with Reflection, but it's not a good practice. Unless you don't care about all .NET code access security issues. Or you can handle that with your own custom handler and setting class.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now