linked config files

  • Thread starter Thread starter Eric Sabine
  • Start date Start date
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>
 
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.
 
Back
Top