N.D
N.D

Reputation: 1049

Configuration system faild to initialize , c# , vs2010

I have a WPF application and I need to work with app.config file. When I tried to build one by adding a new app.config to my project and then add an appSettings to the file , I couldn't read the defined keys from the app.config , I was always getting a null. Then generated app.config file by going to my project's properties, settings and there I defined the values that I needed to use in my application and everything worked just fine . But when I needed to save some values to the config file , I had problems : it didn't work when I tried to add a new setting and define it as a user scope (for editing it in the application) - it just wouldn't save the value in the config file. And when I added manually the appSettings section in the config file and run the application for the first time it did saved the values but the next time I wanted to use those values , the application throw an exception - "Configuration system failed to initialize" . I removed some .vshost files from the c:Users\myuser\AppData\Local\companyName\filename.vshost path that was written in the inner exception and then my application worked again.

I worked as suggested in this post - read write app.config file

But my problem is how to save the values in the app.config and how to read them later , all the solutions in the internet don't work - the application just doesn't save the values... I dont know what to do...

Upvotes: 0

Views: 662

Answers (1)

vim
vim

Reputation: 875

I found that once used User Scope variables, trying removing all of them results in such crash. After trying to change all User Scope settings to Application Scope I ended up putting a dummy User Scope settings which resolve this exception.

Upvotes: 1

Related Questions