0

Everytime I am saving settings with Settings.Default.Save, I notice getting different settings when in debugging mode. I assume this is because of the .vshost.exe debugging process.

I think you my also get different settings running Debug vs. Release binaries.

Is there a simple way to get all calls to Settings.Default.Save to always save in the same location?

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
Derek
  • 7,615
  • 5
  • 33
  • 58
  • `Save` saves *user* settings. User settings are saved in separate folders based on an application's version. If you use automatic version numbering but forget to migrate the settings when you start, you'll lose settings each time you build your application. Check this [probably duplicate question](http://stackoverflow.com/questions/534261/how-do-you-keep-user-config-settings-across-different-assembly-versions-in-net). This actually makes sense because it prevents applications from crashing if the settings schema changes – Panagiotis Kanavos Aug 18 '16 at 10:50
  • I guess my issue is that this is just a developer tool for personal use. I just want one set of settings for the application. – Derek Aug 18 '16 at 18:18
  • Then why do you use per-user settings? Anyway, migrating is just 5 lines, including braces. Even a personal tool will break if it triest to load a new setting from an old file – Panagiotis Kanavos Aug 19 '16 at 09:05
  • 1
    Another option is to simply store a custom settings class to your own file. – Panagiotis Kanavos Aug 19 '16 at 09:07

1 Answers1

1

You have to keep in mind the following things:

User settings
User settings are saved within the user's profile and do not reflect in the .exe.config file in \bin\debug or even the app.config original file.

Running outside Visual Studio vs. Debugging within Visual Studio
When you run an application outside Visual Studio, the user settings will be saved in a different location within your profile than when running the application in Visual Studio. They are treated as if they were different "installations" of the same application.

There is no way that I know of that would cause the mechanism to always read the same file. And it may also not be what you want.

Imagine you have the application running as release version on your system. At the same time you're the developer of the application and you constantly add features, testing them against some test system. You'd frequently overwrite your test-settings with live-settings and vice versa. That's not really what you would want...

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
  • I guess my issue is that this is just a developer tool for personal use. I just want one set of settings for the application. – Derek Aug 18 '16 at 18:18