简体   繁体   中英

.NET settings - different under debugger

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?

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM