System.Configuration namespace

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
 
G

Gary Chang

Hi Steve,

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.


Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
R

runningdog

Thanks Gary,

It was a holiday weekend here so I've only just got back to this.
I does work, the problem was that "user.config" was not copied to the
directory with the .exe and therefore not found.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top