R
runningdog
HI,
Sorry if this is a bit long winded
I'm working on a suite of winapps that need to use two levels of
configuration data; application level and solution level.
I found a reference on MSDN that suggested that app.config file can import
data from another file at runtime.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/tdlg_ch4.asp
So I created a solution and added app.config and user.config as follows
app.config file contains
<configuration>
<appSettings file="user.config">
<add key="testKey" value="Got test key"/>
</appSettings>
</configuration>
user.config file contains
<appSettings>
<add key="ConnectionString" value="Connect String"/>
</appSettings>
I added to my form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
MsgBox(System.Configuration.ConfigurationSettings.AppSettings("ConnectionStr
ing"), MsgBoxStyle.OKOnly)
MsgBox(System.Configuration.ConfigurationSettings.AppSettings("testKey"),
MsgBoxStyle.OKOnly)
End Sub
I expected to see
Connect String
Got test key
I get
<blank>
Got test key
Should this work?
TIA Steve
Sorry if this is a bit long winded
I'm working on a suite of winapps that need to use two levels of
configuration data; application level and solution level.
I found a reference on MSDN that suggested that app.config file can import
data from another file at runtime.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/tdlg_ch4.asp
So I created a solution and added app.config and user.config as follows
app.config file contains
<configuration>
<appSettings file="user.config">
<add key="testKey" value="Got test key"/>
</appSettings>
</configuration>
user.config file contains
<appSettings>
<add key="ConnectionString" value="Connect String"/>
</appSettings>
I added to my form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
MsgBox(System.Configuration.ConfigurationSettings.AppSettings("ConnectionStr
ing"), MsgBoxStyle.OKOnly)
MsgBox(System.Configuration.ConfigurationSettings.AppSettings("testKey"),
MsgBoxStyle.OKOnly)
End Sub
I expected to see
Connect String
Got test key
I get
<blank>
Got test key
Should this work?
TIA Steve