troubleshooting Question

How to add hierarchical data to app.config? How to retrieve it later?

Avatar of yossikally
yossikally asked on
.NET ProgrammingC#SQL
10 Comments1 Solution2367 ViewsLast Modified:
In my Visual C# app I have an app config file as follows:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
      <add key="sizex" value="111" />
      <add key="sizey" value="211" />
  </appSettings>
</configuration>

which works fine, but I want to to look as follows:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <size>
      <add key="x" value="111" />
      <add key="y" value="211" />
    </size>
  </appSettings>
</configuration>

and now I get an exception when trying to access the information
(Unrecognized element 'size'.)

can someone please show how to write it in the app.config file and how to retrieve it IN CODE?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros