0

Issue


I just want to be able to retrieve a value inside my App.Config file but it just does not seem to work.

The code to retrieve the value is:

Dim email As String = ConfigurationManager.AppSettings("stmpFromEmail")

My App.Config:

<configuration>
    <applicationSettings>
        <DataImport.DataImport.My.MySettings>
            <setting name="stmpFromEmail" serializeAs="String">
                <value>AgilityDataImport@agilitylogistics.com</value>
            </setting>
        </DataImport.DataImport.My.MySettings>
    </applicationSettings>
</configuration>

I cannot seem to get the value back, help anyone?

Ben Clarke
  • 1,051
  • 4
  • 21
  • 47
  • 2
    appSetting and applicationSettings are two different sections. See [Pros and cons of appSettings vs applicationSettings](http://stackoverflow.com/questions/460935/pros-and-cons-of-appsettings-vs-applicationsettings-net-app-config) – Steve Jun 30 '16 at 11:41
  • is there a reason you are using applicationSettings vs appSetting ? – coder32 Jun 30 '16 at 12:20
  • @coder32 No not really what do i need to change to get it to work? – Ben Clarke Jun 30 '16 at 12:45
  • okay, then do the below – coder32 Jun 30 '16 at 12:54

1 Answers1

0

Okay, you would have to change your app.config file to be like the below.

<configuration>
<appSettings>                               
<add key="stmpFromEmail" value="AgilityDataImport@agilitylogistics.com"/> 
<appSettings>
</configuration>

Then you can call it like the below.

Dim email As String = ConfigurationManager.AppSettings("stmpFromEmail")
coder32
  • 191
  • 3
  • 12