linked config files

E

Eric Sabine

I am aware you can link to other .config files in your app.config but I am
missing something. What does it take to get this to work?

Sub Main()
Dim appConfig As New AppSettingsReader
Console.WriteLine(appConfig.GetValue("InAppConfig",
Type.GetType("System.String")).ToString)
Console.WriteLine(appConfig.GetValue("InSharedConfig",
Type.GetType("System.String")).ToString)
Console.ReadLine()
End Sub

------app.config-------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings file="shared.config">
<add key="InAppConfig" value="123" />
</appSettings>
</configuration>

-------shared.config---------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="InSharedConfig" value = "456" />
</appSettings>
</configuration>
 
E

Eric Sabine

Solved. The problem was twofold. First, the file needs the path, i.e.,
file="c:\path\path\fileName.config". Second, the root element of the second
config file must be <appConfig>, not <configuration> as I had it.
 

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