1

I created a setting called StartLocation

setting

And then I tried to use it on Form_Load event

var x = Settings.Default.StartLocation;

When I am running my program from withing Visual Studio, I don't get any errors. When I run the compiled version in Debug mode, everything works fine.

But then, when I try to run in Release mode outside Visual Studio I get this error

Configuration system failed to initialize exception

configuration error

My WPower.exe.config file

<?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="WPower.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" />
    </startup>
    <userSettings>
        <WPower.Properties.Settings>
            <setting name="StartLocation" serializeAs="String">
                <value>200, 250</value>
            </setting>
        </WPower.Properties.Settings>
    </userSettings>
</configuration>

I tried cleaning up the solution and recompiling... I tried to overwrite the config file with the on in the debug folder... But I always get this error no matter what.

Why is that? Why when I run in Release outside Visual Studio I get this error?

Full source

BrunoLM
  • 97,872
  • 84
  • 296
  • 452
  • If you look at the `Settings` tab on the `Project` when you have `Release` selected; is the value there? – Mike Perrenoud Nov 18 '13 at 20:05
  • Yes. It is. And it works inside Visual Studio. – BrunoLM Nov 18 '13 at 20:06
  • Are you running it in `Release` on a different machine? – Mike Perrenoud Nov 18 '13 at 20:07
  • Have a look at the answer on this post; http://stackoverflow.com/questions/6436157/configuration-system-failed-to-initialize. Maybe you already have, sorry about that if so. – Mike Perrenoud Nov 18 '13 at 20:10
  • Thanks @MichaelPerrenoud, I had a different application on the same folder with the same name before. Looking at this answer on the question you linked http://stackoverflow.com/a/16332304/340760 I realized that the config might be stored elsewhere. Not exactly where that guy pointed out. I renamed my executable file and config file and it worked! – BrunoLM Nov 18 '13 at 20:15
  • Now I need to know where is this config stored to delete it. – BrunoLM Nov 18 '13 at 20:18

1 Answers1

2

I had a different project on the same folder.

I found that the settings are stored at

...\User\AppData\Local\WPower

So I deleted the old files and re-run the application.

BrunoLM
  • 97,872
  • 84
  • 296
  • 452