简体   繁体   中英

Configuration.Save() in .Net 3.5 does not work in Deploy/Release mode

As suggested on msdn social forum, http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ab59671a-f0a3-4182-ba5b-7fa17f0a6118?prof=required

I turned off the the Visual Studio hosting process and verified that the changes are saved to MyApp.exe.config file instead of MyApp.vhost.exe.config file when still running under Debug configuration. However when I deployed my application with Release configuration to C:\\UAT\\MyApp\\, it would not save the changes to C:\\UAT\\MyApp\\Application Files\\MyAPP_1_0_0_0\\MyApp.exe.config file. I checked file permissions and made sure that ReadOnly is not checked for MyApp.exe.config file.

In addition, I also tried to SaveAs(persist\\MyApp_yyyymmdd.config). While running in Debug mode inside Visual Studio 2008 (vhosting turned off), it does create 'persist' folder under bin/Debug and saves the file there. However the deployed version in C:\\UAT\\MyApp\\ does not create such folder. I made sure all folders under C:\\UAT are not set to ReadOnly.

I am using Visual Studio 2008. Appreciate any help on this.

Follow up: I also made sure that Security was set to 'This is a full trust application' from Project Properties before deploying the application.

Values for user settings are typically saved to a "user.config" in the user's profile, especially for published apps. The exe.config is not really intended to be edited at runtime, as it comes back to the installation (protected by system) vs documents (user) issue, especially for non-admins.

Check for a location such as:

{user profile}\\AppData\\Local{appname}\\{appname}.exe_{gibberish}\\user.config

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