BUG?? App Config and form corruption

C

Chris Dunaway

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.
 
A

Andy Becker

Chris Dunaway said:
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.

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
 
C

Chris Dunaway

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top