2

I have web.config file from some application. It is located in some random location. I have to parse this web.config file (get all keys names and values). I tried to use ConfigurationManager class in order to get those data however, it throws exception when I try to get some Sections (Configuration->GetSection('section name')). It throws exception because I do not have dll that this section points to (because I have only web.config not whole application). It seems that GetSection method check underlying dll in order to get more info, but I just need value (name of dll).

What can I do, to turn off this mechanism, do you know other simple solutions to get it done ?

1

3 Answers 3

7

You are just going to have to use XmlDocument or XDocument (3.5) to parse the file.

Sign up to request clarification or add additional context in comments.

Comments

2

If you just want to read the text, and not do any web.config-specific processing, use the fact that a .config file is XML, and use your favourite usual way of reading and parsing XML.

Comments

2

Web.Config files are just XML and an be read using a number of .Net XML objects. Below are a couple of methods.

Tutorial on reading an XML file using XmlTextReader http://support.microsoft.com/kb/307548

Tutorial on reading an XML file using LinqToSQL http://www.mssqltips.com/tip.asp?tip=1524

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.