By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

BUG?? App Config and form corruption

P: n/a
I was working on a Windows Forms app. The main form had a tab control, a
number of tabs with labels and buttons, etc. It is a new project so not
much work has been completed yet.

I added an app.config file to the project and then added appSettings
section to the file as shown below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="KeyName" Value="Value"
</appSettings>
</configuration>

Notice that I forgot to put the closing tag on the <add element.

The result was hundreds of error like the following in the task list:

Code generation for property 'Text' failed. Error was: 'There was an error
loading app.config. Since the document being loaded uses Dynamic
Properties, the config file must be valid. Correct the following error in
app.config:

This is an unexpected token. The expected token is 'NAME'. Line 5, position
9.'

What happened was that the form designer rewrote many many lines of my
InitializeComponent method and many controls disappeared or were changed.

Fortunately, I had checked the code into source control the day before so I
didn't lose anything. But it seems quite a severe reaction on the part of
the form designer to completely re-write the InitializeCode method just
because of a small ommision.

Has anyone else experienced this sort of thing? Are there any articles
availble that describe this issue in more detail?

Making sure the app.config file is correct seems to have fixed the problem.
--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:1r******************************@40tude.net.. .
I was working on a Windows Forms app. The main form had a tab control, a
number of tabs with labels and buttons, etc. It is a new project so not
much work has been completed yet.

I added an app.config file to the project and then added appSettings
section to the file as shown below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="KeyName" Value="Value"
</appSettings>
</configuration>

Notice that I forgot to put the closing tag on the <add element.

The result was hundreds of error like the following in the task list:

Code generation for property 'Text' failed. Error was: 'There was an error loading app.config. Since the document being loaded uses Dynamic
Properties, the config file must be valid. Correct the following error in
app.config:

This is an unexpected token. The expected token is 'NAME'. Line 5, position 9.'

What happened was that the form designer rewrote many many lines of my
InitializeComponent method and many controls disappeared or were changed.

Fortunately, I had checked the code into source control the day before so I didn't lose anything. But it seems quite a severe reaction on the part of
the form designer to completely re-write the InitializeCode method just
because of a small ommision.

Has anyone else experienced this sort of thing? Are there any articles
availble that describe this issue in more detail?

Making sure the app.config file is correct seems to have fixed the problem. --
Chris


Wild. Are any of your controls, either intentionally or unintentionally,
accessing ConfigurationSettings in their constructors or properties? It
sounds like something is, and might need to be "protected" with a test for
Me.DesignMode. I am confused as to why it would actually find/read the
config file at design time, though?

Best Regards,

Andy
Nov 21 '05 #2

P: n/a
On Tue, 17 Aug 2004 10:39:22 -0500, Andy Becker wrote:

Wild. Are any of your controls, either intentionally or unintentionally,
accessing ConfigurationSettings in their constructors or properties? It


Not that I can tell. The xml I posted in my original post was the enitre
app.config file. I had just forgotten to include the closing tag on the
<add> element. That is what caused it.

To me, this is a bug. If the designer detects that the app.config is not
well formed then it should abort the code generation phase and report the
error.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.