1

In Visual Studio, when I build a WPF app, then in the output folder containing my program there's 3 files:

  • MyProgram.exe
  • MyProgram.exe.config <--
  • MyProgram.pdb

There's a .config file located in the following dir as well:

'%Appdata%\Local{MyProgram}.exe_Url_{random string}{version}\user.config <--


Contents

MyProgram.exe.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="QuickEmoji.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    <userSettings>
        <QuickEmoji.Properties.Settings>
            <setting name="Startup" serializeAs="String">
                <value>True</value>
            </setting>
            <setting name="FirstRun" serializeAs="String">
                <value>True</value>
            </setting>
            <setting name="Minimized" serializeAs="String">
                <value>True</value>
            </setting>
        </QuickEmoji.Properties.Settings>
    </userSettings>
</configuration>

user.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="QuickEmoji.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <userSettings>
        <QuickEmoji.Properties.Settings>
            <setting name="FirstRun" serializeAs="String">
                <value>False</value>
            </setting>
            <setting name="Startup" serializeAs="String">
                <value>True</value>
            </setting>
            <setting name="Minimized" serializeAs="String">
                <value>True</value>
            </setting>
        </QuickEmoji.Properties.Settings>
    </userSettings>
</configuration>

Do I need this .config file for my program to run correctly? I've compiled a lot of projects and all of them worked perfectly fine without it, just asking to be sure.

symonxd
  • 21
  • 1
  • 8

1 Answers1

1

The App.config file is optional, so you don't need to run your program. Nevertheless, that file exists for you to put your settings there, like your connection strings or any other configuration for your application, other libraries (like Log4Net) or other frameworks (like WCF).

You should read this article.

Marlonchosky
  • 494
  • 5
  • 16
  • Very informative article, thank you! Although it's not quite clear yet, probably due to my phrasing... So, let't say I implement a setting. Do I need the file for sure? Because I remember going into the 'AppData' folder and finding there my app and the .config with it. Is it a different file? – symonxd Apr 20 '20 at 01:03
  • I don't know this file, sorry. But I suggest you should try to rename it to xyxy.config.bak and verify if your program run correctly. – Marlonchosky Apr 20 '20 at 01:31
  • AFAIK I can delete it perfectly fine, it would just get regenerated with the settings reset. Thanks for the help though! – symonxd Apr 20 '20 at 02:08