0

I've been reading and searching for how to make this work but I can't manage to get my app to reload or refresh it's loaded settings. This is a section I have in my exe.config:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Tekla.Structures.Model" publicKeyToken="2f04dbe497b71114" culture="neutral" />
        <bindingRedirect oldVersion="17.0.0.0-99.1.0.0" newVersion="18.1.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

I need to change the newVersion to 18.0.0.0 which I can do easily. The problem is once I do, I can't get the app to load that information without starting the app from scratch manually.

I've tried all these combinations based on my searches but none seem to work:

System.Configuration.ConfigurationManager.RefreshSection("runtime");
System.Configuration.ConfigurationManager.RefreshSection("assemblyBinding");
System.Configuration.ConfigurationManager.RefreshSection("runtime/assemblyBinding");
System.Configuration.ConfigurationManager.RefreshSection("runtime/assemblyBinding/dependentAssembly");
System.Configuration.ConfigurationManager.RefreshSection("runtime/assemblyBinding/dependentAssembly/bindingRedirect");

What do I need to do to get this to reload?

Mutley
  • 77
  • 2
  • 13
  • Have a look at this SO post http://stackoverflow.com/questions/325788/how-to-update-assemblybinding-section-in-config-file-at-runtime – Alex Jan 17 '14 at 06:53
  • Thanks, it seems it's not possible so I found another solution to what I really want to do. – Mutley Jan 23 '14 at 03:22

1 Answers1

0

You just need to save the config file in Modified Mode and then refresh this will make application to read the file agian from the disk.

ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).Save(ConfigurationSaveMode.Modified);

ConfigurationManager.RefreshSection("appSettings");
Ramashankar
  • 1,598
  • 10
  • 14
  • @Alex: You are right binding only resolve on startup. The above code only refresh/reload config file. – Ramashankar Jan 17 '14 at 06:58
  • Thanks, it seems it's not possible to update bindings constantly so I found another solution to what I really want to do. – Mutley Jan 23 '14 at 03:22