August 19, 2005

Failed to save settings

Error: Failed to save settings: An error occurred executing the configuration section handler for userSettings/XYZ.Properties.Settings. (C:\Documents and Settings\Administrator\Local Settings\Application Data\amastaneh\XYZ.exe_Url_znuhtk3o00xt5ahfq5tlsmqqiclldnz5\1

I had a big problem with this error because every thing came normal but i had one error on Settings.Default.Save() method.
I think that, You can correct this error from app.config file.
I know that you wanna say this file is OK but i must tell you that i was like you, too.
However, you can test this way.
In this way you can build a sample application and then go to app.config and copy/past some line form first.
You must compare these codes with your uncorrected app.config file.
This is a section of my corrected app.config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="XYZ.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" />
</sectionGroup>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="XYZ.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</sectionGroup>
</configSections>
....
I hope this helps, Be happy.

2 comments:

Szymon said...

I just started recieving the same error in my application. Strangely the same app works fine on another machine. In my program this error is rised when I try to read some properties from app.config (I'm not saving anything just yet). In fact I observed it is thrown from System.Security.Policy.PolicyLevel.GenericResolve() method so it might have something to do with security settings. I don't fully understand your solution. Could you explain in detail what is the cause and how to solve this?

amastaneh said...

TO SZYMON DEAR
Sorry for late. My way is not a solution, it’s just a trick which used for repairing CONFIG file comparing to the safe file but your problem is another kind.
Whenever you solved your problem, share it please ;-)