Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# error:Unrecognized configuration section userSettings - stop program reading user.config?

Tags:

In my c# form application (created in VS2010, using .NET 4.0) I use an application setting to store an output path.

Previously this setting was configured with a user scope, but I had to change its scope to application.

After doing this I now get an Unrecognized configuration section userSettings error on start up of the form (note the program has been executed before with the setting's scope set to user):

InnerException: System.Configuration.ConfigurationErrorsException    Message=Unrecognized configuration section userSettings. (C:\Documents and Settings\Administrator\Local Settings\Application Data\CallCenterForm\CallCenterForm.vshost.exe_StrongName_bplf30wziudnpq0knzaacfuyomd5rv45\1.0.0.0\user.config line 3)    Source=System.Configuration    BareMessage=Unrecognized configuration section userSettings.    Filename=C:\Documents and Settings\Administrator\Local Settings\Application Data\CallCenterForm\CallCenterForm.vshost.exe_StrongName_bplf30wziudnpq0knzaacfuyomd5rv45\1.0.0.0\user.config 

So after doing some browsing this seems to be caused by the old user.config file still existing on the system, causing the program to read it and throw an error (I'm not sure what the actual underlying problem is). I can also confirm that when I remove the file the problem goes away.

Which brings me to my question, is there a way I can change the program so that it won't read the old user.config file, because deleting it manually isn't ideal as the program is already in production on multiple systems.

Apologies if this has been covered, but I couldn't find an answer.

In case it's helpful here's the contents of my App.config file:

<?xml version="1.0" encoding="utf-8" ?> <configuration>   <configSections>     <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >       <section name="CallCenterForm.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />     </sectionGroup>   </configSections>   <startup useLegacyV2RuntimeActivationPolicy="true">     <supportedRuntime version="v4.0"/>   </startup>   <applicationSettings>     <CallCenterForm.Properties.Settings>       <setting name="saved_output_dir" serializeAs="String">         <value>c:\</value>       </setting>     </CallCenterForm.Properties.Settings>   </applicationSettings> </configuration> 
like image 230
dancypants Avatar asked Nov 08 '12 22:11

dancypants


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.


1 Answers

I ran into this error myself today. The solution was to go into the Assembly Information dialogue of the project's properties and advance the assembly and file version info (ex. 1.0.0.0 to 1.0.1.0), save the changes, and rebuild the application. This will cause the compiler to reevaluate the configuration and cause the application to refrain from creating and reading a new user.config file corresponding to the new version due to there being no user settings in the new version.

like image 175
Collie Avatar answered Sep 30 '22 07:09

Collie