Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

Reading ApplicationSettings

a Web service has put this ApplicationsSettings section in my app.config.

How do I read this url from this section in c# (VS2008)?

TIA

<applicationSettings>
    <Andy.Properties.Settings>
      <setting name="Andy_WS_AWS" serializeAs="String">
        <value>http://server:85/soap.slap</value>
      </setting>
    </Andy.Properties.Settings>
  </applicationSettings>

Open in new window

0
Philip Pinnell
Asked:
Philip Pinnell
  • 3
  • 2
1 Solution
 
Philip PinnellAuthor Commented:
Yeah, I've done straight forward settings like

<configuration>
    <appSettings>
        <add key="ExportPath" value="C:\\Tmp" />        
    </appSettings>
</configuration>

But the above is in a different format and

ws.Url = System.Configuration.ConfigurationSettings.AppSettings["Andy_WS_AWS"];

does not work.

0
 
CuteBugCommented:
Declare your config as given below

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Andy_WS_AWS" value="http://server:85/soap.slap" />
  </appSettings>
</configuration>

Now you can query it this way
using System.Configuration;

AppSettingsReader ar = new AppSettingsReader();
string val =  ar.GetValue("Andy_WS_AWS", typeof(string)) as string;
Console.WriteLine(val);
0
 
Philip PinnellAuthor Commented:
Yeah, I guess I could do it like that but that is not the question. The question is, how do I read it when it *is* like the above config. That is what I want to know.
0
 
Philip PinnellAuthor Commented:
It seems that this construct actually provides intellisense and thus the item in question can be retrieved by

myURL = Andy.Properties.Settings.Default.Andy_WS_AWS.ToString();


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.

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