linkedConfiguration information not shown in ConfigurationManager

Hi,

I'm having difficulty in getting the linked configuration to work correctly. I have the following element in my app.config file but it fails to show the information from the general configuration in configuration manager when the program has run.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<linkedConfiguration href="file://c:\MyFolder\MyGenereal.config"/>
</assemblyBinding>

I know that the url is correct as i can ctrl - left click it and VS doesn't show any exceptions when i debug the app using F5.

Any ideas

Thanks in advance

JK



Answer this question

linkedConfiguration information not shown in ConfigurationManager

  • DLdfrd

    In case someone is still looking for a resolution of this issue, there isn't any because this behaviour is by design, at least in .NET 2.0.
    Look here for more info.
    It says:

    "The rules for linkedConfiguration are:

    1. This feature is only meant for fusion binding policies. Only fusion understands the syntax. The included config files can have settings other than binding policies. But those settings won’t be read by anyone, nor will they have any effect.
    2. Only file:// HREF linked configurations are allowed. This includes local files, as well as UNC files.
    3. There is no constraint on the number of linked configurations per config file.
    4. The semantics is like #include in C/C++. In other words, all the linked configuration files are merged together to form one config file.
    5. This feature is only allowed in app.config. They are ignored if they are present in publisher policy/machine.config.
    6. We break the cycle if there is any."
    It means that only assembly binding sections are recognized in included configuration file and appSettings are simply ignored.


  • Tryst

    Anyone any ideas

    Anyone ever got this to work Does it work with appSettings and connectionStrings.

    Thanks in advance...

  • DARKGuy

    It really doesn't work :(

    I tried this:

    main.cs:

    public class Tester  {

      public static void Main() {

       Console.WriteLine("appSettings: " + ConfigurationManager.AppSettings.Count);

    }

    }

    main.exe.config:

    <configuration>
       <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <linkedConfiguration href="main-add-config.xml"/>
       </assemblyBinding>

    </configuration>

    main-add-config.xml:

    <configuration>
     <appSettings>
      <add key="key" value="some value"/>
     </appSettings>

    </configuration>

    If we compile and run we'll see:

    appSettings: 0

    If we transfer appSettings from main-add-config.xml into main.exe.config and run again, we'll see:

    appSettings: 1

    I tried different formats of href attribute: "main-add-config.xml", "file://main-add-config.xml", "file://c:\main-add-config.xml". It doesn't matter.

    I have no any idea what's wrong...



  • barkest

    One last try to see if anyone out there is using this successfully

  • linkedConfiguration information not shown in ConfigurationManager