[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Read Specialized Config File

Posted on 2005-04-15
6
Medium Priority
?
273 Views
Last Modified: 2012-08-14
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
Comment
Question by:ten_spoons
  • 4
  • 2
6 Comments
 
LVL 20

Expert Comment

by:ihenry
ID: 13796215
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
 

Author Comment

by:ten_spoons
ID: 13805888
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
 
LVL 20

Expert Comment

by:ihenry
ID: 13806594
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:ihenry
ID: 13806607
0
 

Author Comment

by:ten_spoons
ID: 13807264
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
 
LVL 20

Accepted Solution

by:
ihenry earned 500 total points
ID: 13808172
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question