I started getting a very unexpected error today in the application I’m working on. I did a quick search on google and resorted to asking a question on the StackOverflow website
The key ‘UserID’ does not exist in the appSettings configuration section.Basically, I started getting this error while trying to open 2 of some 10+ forms in my Window Forms application in designer.
To prevent possible data loss before loading the designer, the following errors must be
resolved:
The key 'UserID' does not exist in the appSettings configuration section.
While waiting for a kind soul to reply to my question, I continued searching through Call Stacks, trying to find the cause of a problem. And I found it eventually. What the VS designer was really complaining about, was the fact that I was calling a stored procedure from the user control’s InitializeComponent.
Well, I have a couple of comboboxes on the user control which a populated from the database, so I decided to choose the simplest way to make sure they were populated by the time the user control was shown. Looks like it was not such a good idea. I ended up moving the calls into a separate function, and calling that function from a hosting form after the user control is shown in the hosting form. This appears to work for me. Took me a whopping 58 minutes to fix an error I introduced by being careless and ignorant, hope it’s not project-breaking thing.
by Evgeny. Also posted on my website
No comments:
Post a Comment