0

Is it possible to read the setting value URL using ConfigurationManager ? I'm trying to read this section, but all I get it's null values. I could parse it using XmlDocument... I have already looked for this question within this forum but all I get is ways to get connectionstring, which is quite easy since ConfigurationManager has a ConnectionString Method.

  <applicationSettings>
    <ProjectoGlobal.Properties.Settings>
      <setting name="ProjectoGlobal_WebServicePg_SyncPgData" serializeAs="String">
        <value>http://localhost/SarfWebService/SyncPgData.asmx</value>
      </setting>
    </ProjectoGlobal.Properties.Settings>
  </applicationSettings>

Thanks

Nuno
  • 126
  • 2
  • 14

3 Answers3

3

Well, you can access it using:

Properties.Settings.Default.ProjectoGlobal_WebServicePg_SyncPgData

Here's MSDN reference: http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx

Thanks for all -1's ;)

Selman Genç
  • 100,147
  • 13
  • 119
  • 184
Aleksandar Toplek
  • 2,792
  • 29
  • 44
  • That definitely works... But it's not with configurationManager.. Thanks – Nuno Jan 26 '14 at 15:36
  • @Nuno it's not the same thing... take a look at this: http://stackoverflow.com/questions/460935/pros-and-cons-of-appsettings-vs-applicationsettings-net-app-config – Aleksandar Toplek Jan 26 '14 at 15:38
0

I think this would do:

string setting = yourprojectname.Properties.Settings.Default.ProjectoGlobal_WebServicePg_SyncPgData;

EDIT:

ok using the configuration manager just for demonstration purposes:

Configuration conf;

this.conf = ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);

ConfigurationSectionGroup sectionGroup = this.conf.GetSectionGroup("applicationSettings");

ClientSettingsSection section =
(ClientSettingsSection)sectionGroup.Sections.Get("ProjectoGlobal.Properties.Settings");

SettingElement setting = section.Settings.Get("ProjectoGlobal_WebServicePg_SyncPgData");

string result = setting.Value.ValueXml.InnerText;

you should use the first option though...

terrybozzio
  • 4,424
  • 1
  • 19
  • 25
0

It is very simple:

<configuration>
  <appSettings>
    <add key="myHttpString" value="http://localhost/SarfWebService/SyncPgData.asmx" />
  </appSettings>
</configuration>

Documentation: MSDN

Alberto Solano
  • 7,972
  • 3
  • 38
  • 61