Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred while saving values to the app.config file #8207

Closed
Tracked by #8058
vsfeedback opened this issue Nov 30, 2021 · 6 comments
Closed
Tracked by #8058

An error occurred while saving values to the app.config file #8207

vsfeedback opened this issue Nov 30, 2021 · 6 comments
Assignees
Labels
Feature-Settings-Designer Specific to the settings file designer. Triage-Approved Reviewed and prioritized
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


The application settings designer is no longer able to update the App.config file. This goes back several versions of VS before current.

Steps to reproduce:

  • Create a new WPF App (.Net Core) project
  • Add application settings file to the project (via add new item dialog)
  • Add App.config file
  • Add some setting to the settings file (through the settings designer), save it
  • Change an existing or add a new setting to the settings file, save it again

Expected results:

  • Application settings designer should automatically update the App.config file

Actual result:

  • An error shows up saying "An error occurred while saving values to the app.config file..."

The settings designer does update the App.config at first but any subsequent updates will result in the aforementioned error.


Original Comments

Feedback Bot on 6/27/2020, 08:11 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Sam Harwell [MSFT] on 7/6/2020, 04:44 PM:

Thank you for providing feedback, and we’re sorry to hear it’s not behaving as you expect. Based on your description so far, it sounds like you are experiencing a problem which is historically hard to diagnose and resolve using the normal “steps to reproduce”. We created a set of instructions for providing additional information which will help us track down the true source of the problems.

Based on the information provided so far, the most likely scenario to follow is for “Performance issues”. Please look at the following document to provide the feedback most relevant for the problems you would like to see fixed: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-increase-chances-of-performance-issue-being-fixed?view=vs-2019#slowness-and-high-cpu-issues

Feedback Bot on 7/14/2020, 09:43 PM:

We will close this report in 14 days because we don’t have enough information to investigate further. To keep the problem open, please provide the requested details.

Sala, Bojan on 7/17/2020, 04:05 AM:

Hi Sam, I am not sure what information I need to provide. I can attach an example solution for you if that would help?

It's extremely easy to reproduce the bug, it seems to simply be an issue where developers overlooked a scenario where one would prefer using App.config file in a .Net Core app.

Feedback Bot on 7/20/2020, 08:22 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Feedback Bot on 9/23/2020, 11:31 PM:

I have detected that for the last 90 days, this issue didn't have much product team activity and a very small amount of new votes or comments. Based on this, its severity, and affected area, it’s my experience that this issue is very unlikely to be fixed.

Robert Howell on 2/1/2021, 06:37 AM:

I also have the identical problem. I am using .NetCore 3.1 with Wpf. I can added the first setting fine, but subsequent settings seem to add but when I click Save I get the error above and the app.config file is not updated. Only the first entry appears

Vernon Martin on 2/21/2021, 03:25 AM:

(private comment, text removed)

Vernon Martin on 2/21/2021, 03:35 AM:

(private comment, text removed)

Vernon Martin on 2/21/2021, 05:03 AM:

I have the same issue.

My work around: initial creating of Setting.settings is no issue. Add a setting or two. Saved. Committed to source code control for safe keeping. When the error occurs, I close my settings and revert to previously working copies of settings and app.config. Then I add my new settings (or remove or modify) manually in app.config file, then open Setting.settings and allow it to add the new setting. then I save settings and ignore the error message about in invalid XML. Life goes on with no noticeable consequences.

Vernon Martin on 3/15/2021, 00:51 PM:

It seems if you do that, you’d loose other settings in the APP.config file. Is that true?


Original Solutions

帕菲菲 solved on 3/12/2021, 05:01 AM, 0 votes:

[Workaround]
Still not fixed until this post.
Fortunately, the settings are not basically saved in App.config. It’s actually saved in “My Project\Settings.settings”. App.config just contains an uncritical copy. Based on this, the workaround is:

  1. Do exactly one random change to the design of your setting.
  2. Delete the App.config file, which will cause the settings designer to close itself automatically.
  3. Open the settings designer again and change your settings back. Save.
  4. Error still occurs, but you’ll see the App.config recreated with correct settings.
@mairaw mairaw transferred this issue from dotnet/core Nov 30, 2021
@cbmason
Copy link

cbmason commented Dec 21, 2021

I also have this problem, reproducible in the exact same way as described.

@vishalmsft
Copy link

@mairaw Thank you for looking into the bug.
As commented on
FeedbackTicket 1147377: An error occurred while saving values to the app.config file.
This needs to be fixed in the Visual Studio designer.

@vishalmsft vishalmsft transferred this issue from dotnet/wpf Dec 22, 2021
@ptoye
Copy link

ptoye commented May 21, 2022

I have this problem also. Thanks to @帕菲菲 for the workaround (which I've not had time to try yet). Surely things like this should work 'out of the box' without users having to work out manual intervention for themselves. VS is a tool for use, and has been around for years.

I agree with @mairaw that it needs to be fixed - but how and when?

I've now tried the workaround exactly as described, and get into an even worse state. When accessing the setting I get an error;

SettingsError1

I've had this error before - it seems that errors thrown by incorrect VS-generated files also screw up the diagnostics reporting.

I've a nasty feeling that we're getting back to the good old (?) days of programming - back in the 1960s IBM found that for each bug they eliminated they introduced 1.2!

@mairaw
Copy link

mairaw commented May 25, 2022

@timheuer can you help route this to the appropriate place? This was moved from the developer community site to the repo, but if this is a designer issue, maybe the original ticket should be reopened?

@timheuer timheuer transferred this issue from dotnet/core May 25, 2022
@timheuer
Copy link
Member

Related #6784

@tmeschter tmeschter added Feature-Settings-Designer Specific to the settings file designer. Bug Triage-Approved Reviewed and prioritized labels May 26, 2022
@tmeschter tmeschter added this to the 17.3 milestone May 26, 2022
@kvenkatrajan kvenkatrajan assigned ocallesp and unassigned melytc Jun 21, 2022
@ocallesp
Copy link
Contributor

ocallesp commented Jun 21, 2022

It does not repro "An error occurred while saving values to the app.config file..." taking into consideration
"The settings designer does update the App.config at first but any subsequent updates will result in the aforementioned error."

Tested in:
Microsoft Visual Studio Enterprise 2022 (64-bit) - main
Version 17.3.0 Preview 3.0 [32621.101.main]

This was tested in VB and C#
Steps to reproduce:

  1. Create a new WPF App (.Net Core) project
  2. Open Add New Item dialog and add a "Settings File". Settings1.setting
  3. Open Add New Item dialog and add a "Application Configuration File". App.config
  4. Add some setting to the Settings1.settings file (through the settings designer), save it
  5. Change an existing or add a new setting to the Settings1.settings file, save it again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-Settings-Designer Specific to the settings file designer. Triage-Approved Reviewed and prioritized
Projects
None yet
Development

No branches or pull requests

10 participants