Changing App.config at Runtime

后端 未结 4 1985
旧时难觅i
旧时难觅i 2020-12-01 13:29

I\'m writing a test WinForms / C# / .NET 3.5 application for the system we\'re developing and we fell in the need to switch between .config files at runtime, but this is tur

4条回答
  •  粉色の甜心
    2020-12-01 14:11

    My guess is you are not really closing the file handle the first time so windows does not "see" you making the later changes.

    My suggestions is to use an API call to IIS and turn off the web app (and pool), make the change, turn on the web app. This way you are sure it will re-read the file and have a "clean" environment for each test.

提交回复
热议问题