question

PeterToye-7719 avatar image
0 Votes"
PeterToye-7719 asked PeterToye-7719 commented

An error occurred when trying to save user setting in VS to app.config

I've written a simple Hello Word program to test the use of settings. I set up a simple setting and tried to save it but got an error message (see screenshot). I've looked at the app.config file and the relevant section says

  <userSettings>
     <Hello2.My.MySettings>
         <setting name="Test" serializeAs="String">
             <value />
         </setting>
     </Hello2.My.MySettings>
 </userSettings>

This seems to have two problems:

  1. The setting name is wrong (should be 'TextSet')

  2. There's no value (probably as a result of the error).

I'm using VS 2019 version 16.11.15 on Windows 10 Home. The project was built using the Windows Forms App template.

I'm obviously doing something fairly elementary wrong here, but can't work out what. Surely something as simple of this should just work out of the box.

203694-appconfig-bug.png






vs-general
appconfig-bug.png (14.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AnnaXiu-MSFT avatar image
1 Vote"
AnnaXiu-MSFT answered PeterToye-7719 commented

Hi @PeterToye-7719 ,

Welcome to Microsoft Q&A!

It looks like that the setting shown in the App.config file doesn’t match the setting in Settings.settings. If you manually edit the setting name in App.config, was a new value added automatically in Settings.settings file?

If it doesn’t work, please close all Visual Studio instances and repair your VS through Visual Studio Installer > More > Repair.

Then, create a new Windows Forms App and add a setting in Settings.settings file.
Clicking on Save and check if you can see the setting in App.config file.

If you still have the problem, it may be a known issue: An error occurred while saving values to the app.config file.
You can add your comment there.

Sincerely,
Anna


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You're right - it looks like the bug is known, and there's a workaround there (which I've not had time to try out yet). Thanks @AnnaXiu-MSFT for pointing that out.

0 Votes 0 ·