Simple sample demonstrating the problem consists of a solution containing a
class project and a windows form project. I put the same in a new thread
also, hope thats OK.
Here's the class code snippet
Imports System.Configuration.ConfigurationManager
Public Class Class1
Public _strTestSetting As String
Public Sub SetTestsetting()
_strTestSetting = AppSettings.Get("TestSetting") -should get the value of
TestSetting in app config file
End Sub
End Class
This is the snippet in the project calling the class -Project TestIt - To
test you should have a setting named TestSetting application scope, value
Testvalue
Imports System.Configuration
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim mycls As New clsTestconfig.Class1
mycls.SetTestsetting()
Label1.Text = mycls._strTestSetting
End Sub
End Class
There's a setting TestSetting in the settings file of the project Testit
Put a breakpoint on line
_strTestSetting = AppSettings.Get("TestSetting")
Click the button, you will see as you step over the breakpoint that the
value of _strTestSetting stays at nothing. ie, its not picking up the value
of TestSetting in app.config.
How can I get this pickup of the value to work? By the way I tested in the
IDE and the exe itself. Both failed same way.
Thanks for any help
Bob
"Steve Long" <St**********@NoSpam.comwrote in message
news:uK**************@TK2MSFTNGP06.phx.gbl...
How 'bout the case of the variable. XML is case sensitive.
S
"Robert Dufour" <bd*****@sgiims.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Thanks for your help. Still having a problem though. I referenced the new
configuration manager class. The wavy warning is gone and my code
executes without any exceptions, BUT it does not pick up any of the
values in the config file.
When I single step over the following line in the debugger strTemp
remains empty but there is a value for it in the config file.
Dim strTemp As String = AppSettings.GetString(strKey) - strkey is a
variable passed to this procedure, the spelling of the variable value is
correct.
Isn't high tech fun?
Thanks for your help
Bob
<Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0 .1...
>>"Robert Dufour" <bd*****@sgiims.comwrote in news:#Y9IKePCHHA.3836
@TK2MSFTNGP02.phx.gbl:
Hi, when I try that
Dim strTemp As String = AppSettings("mysetting")
I get the wavy blue underlines and "appsettings is a type and cannot
be
used as an expression".
You need to import the ConfigurationSettings class
(System.Configuration)
or the new Configuration Manager class (you need to reference the
System.Configuration DLL).