Why (and how) is Visual Studio creating <app>.exe.config.deploy which has old app.config settings?

Ken Smith 130 Reputation points
2025-02-17T20:00:54.67+00:00

I lost a week trying to get my Web Reference to use HTTPS instead of HTTP. I finally had to rename my web service because the old settings (with old data) appear in the <app>exe.config.deploy file. Those old settings in <app>exe.config.deploy must be overriding my app.config! I don't know how to get rid of the old stuff in the <app>exe.config.deploy. Here is an interesting fact that makes things even more confusing! When I run in debug mode, it uses HTTPS as specified in app.config. When I run in release mode, it uses HTTP (I don't know why but it seems related to the same reason that my <app>exe.config.deploy gets the old HTTP settings!) Ok. Here are some code samples:

<applicationSettings>
  <HNPcharts.Properties.Settings>
    <setting name="HNPcharts_interfaxV2_InterFax" serializeAs="String">
      <value>https://ws.interfax.net/dfs.asmx</value>
    </setting>
  </HNPcharts.Properties.Settings>
</applicationSettings>

Here is what ends up in <app>.exe.config.deploy (note it has the old name; new name has V2). Also note my new settings specify https, whereas the old settings (which I can't get rid of in <app>exe.config.deploy) specify http.

<applicationSettings>
    <HNPcharts.Properties.Settings>
      <setting name="HNPcharts_interfax_InterFax" serializeAs="String">
        <value>http://ws.interfax.net/dfs.asmx</value>
      </setting>
    </HNPcharts.Properties.Settings>
  </applicationSettings>

So, it seems to me, that my code would never work (used HTTP instead of HTTPS) because the old settings in <app>.exe.config.deploy would override my app.config! I worked around this problem by renaming the web service InterfaxV2 instead of Interfax. Can anyone explain how to get old stuff out of <app>.exe.config.deploy and/or how to get it updated with new settings in app.config?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,447 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 33,361 Reputation points Microsoft Vendor
    2025-02-19T09:28:58.2333333+00:00

    Hi @Ken Smith ,

    If you try to remove the publish folder, the bin folder, the obj folder, and the hidden .vs folder manually. After that open VS, select the Release mode, rebuild your project, publish it again, will this issue disappear?

    Besides, if you try to right-click you project => Unload Project => right-click it again => select Edit Project File => then check the project file, especially the properties about <Publishxxxxxx>, <PropertyGroup Condition = "'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> and <PropertyGroup Condition = "'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> parts, will you see some special settings which may cause this issue?

    1 person found this answer helpful.
    0 comments No comments

  2. Ken Smith 130 Reputation points
    2025-02-19T14:25:18.85+00:00

    Tianyu Sun suggested... remove the publish folder, the bin folder, the obj folder, and the hidden .vs folder manually. After that open VS, select the Release mode, rebuild your project, publish it again.

    That suggestion solved my problem. Many thanks to Tianyu Sun! I would like to mark Tianyu Sun's response as the answer but this tool is not allowing it. In any case, Tianyu Sun deserves the credit.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.