Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Assembly Version redirect doesn't work with a configSource in

$
0
0
Hi,

    We have built a framework for our Company. It includes about 40 assemblies (about 7 services).
We have just delivered a new version (v1.2) of this framework.  Each team using our framework must now decide to use or not this new version.

To facilitate the upgrade, we want to provide the settings to redirect the assembly version at the Application Level. Those settings will have to be added into the applications config files; we may not do it at the Machine Level and we can't force all the applications to use the new version of the framework (Application running in Prod must continue to run without any impact).

Because its a long list of settings, we want to put them in a separated config file and ask the teams to use it as an external source in their own web.config.Ex.: <runtimeconfigSource="BindingRedirect.config" />

This does not work... It's really wierd because the result is 100% the same from a ConfigurationManager point of view. 

We did a small test application (See here after). We run it once with the settings in the configSource and once with the settings directly in the application's config file. In both case, the <runtime> section contains the same settings. But when we use the configSource, the application does not load the new version of the framework.

Here is the code to test:

IgnoreSection runtime = (IgnoreSection)ConfigurationManager.GetSection(@"runtime");

Debug.Print(SerializeSection<IgnoreSection>(runtime));

ConfigurationSection section = (ConfigurationSection)ConfigurationManager.GetSection(@"ourCustomSection");

Debug.Print(section.GetType().AssemblyQualifiedName);


publicstaticstring SerializeSection<TSection>(TSection mySection) where TSection : ConfigurationSection

{

string sectionName = mySection.GetType().FullName;

MethodInfo info = mySection.GetType().GetMethod("SerializeSection", BindingFlags.NonPublic | BindingFlags.Instance);

return info.Invoke(mySection, newobject[] { null, sectionName, ConfigurationSaveMode.Full }) asstring;

}

Here is the Debug output when using configSource:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Framework" publicKeyToken="f510307097254a31" />
        <bindingRedirect oldVersion="1.1.0.0" newVersion="1.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
Framework.ourCustomConfigurationSectionFramework, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f510307097254a31

Here is the Debug output when NOT using configSource but settings the bindings directly in the application's config file.

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Framework" publicKeyToken="f510307097254a31" />
      <bindingRedirect oldVersion="1.1.0.0" newVersion="1.2.0.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>
Framework.ourCustomConfigurationSectionFramework, Version=1.2.0.0, Culture=neutral, PublicKeyToken=f510307097254a31


Any idea why it's not working ? Any workarround to avoid that each team must copy/paste this long list of settings in its own config file ? I my understanding, using a Policy file assembly (that has to be in the GAC) will redirect all the assembly versions for all the applications and is therefore not acceptable for us...

V.


Viewing all articles
Browse latest Browse all 1710

Trending Articles