• 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" ?>
<configuration>

  <configSections>
    <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" />
  </configSections>
   
  <appSettings>
    <add key="siteRoot" value="/" />
    <add key="imageRoot" value="/Images/" />
  </appSettings>
  <DatabaseInformation>
    <connections>
      <connection id="Reader" dataProvider="SqlConnection">
                          <connectionString>Server=Production;database=Network;uid=PRead;pwd=PReadPass;</connectionString>
                 </connection>
      <connection id="Writer" dataProvider="SqlConnection">
                          <connectionString>Server=Production;database=Network;uid=PWrite;pwd=PWritePass;</connectionString>
      </connection>
    </connections>
</configuration



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

Thanks much.
0
ten_spoons
Asked:
ten_spoons
  • 4
  • 2
1 Solution
 
ihenryCommented:
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?
0
 
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.
0
 
ihenryCommented:
Some tutorials to get you started.

Creating Custom Configuration Settings in ASP.NET
http://www.devx.com/dotnet/Article/16927

Using Application Configuration Files in .NET
http://www.codeguru.com/Csharp/Csharp/cs_misc/designtechniques/article.php/c7987__2/

Creating a Flexible Configuration Section Handler
http://www.15seconds.com/issue/040504.htm

HOW TO: Create a Custom ASP.NET Configuration Section Handler in Visual Basic .NET
http://support.microsoft.com/kb/318457/EN-US/

0
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.

 
ihenryCommented:
0
 
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.
0
 
ihenryCommented:
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.
0
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