Incorrect InitializeComponent/.RESX Code Serialization

S

Sean J Donovan

When you have a control, and Localizable = FALSE, all child controls
serialize into the InitializeComponent method. There are some
exceptions, eg. Images have their value written into the .resx file.

Eg. this.label1.Location = new System.Drawing.Point(104, 64);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "Hello";

If you have a control that has Localizable = TRUE, when all child
controls are code-serialized, the actual values are typically written to
the .resx file.

Eg. this.label1.AccessibleDescription =
resources.GetString("label1.AccessibleDescription");
this.label1.AccessibleName =
resources.GetString("label1.AccessibleName");
this.label1.Anchor =
((System.Windows.Forms.AnchorStyles)(resources.GetObject("label1.Anchor")));


PROBLEM #1:

However, we have a case where the Localizable = FALSE, and the
properties are still in the .resx, IMHO, they shouldn't be, and it's a
bug. Has anyone else seen this?

Specifcally, we have a enum property, defined as:

/// <summary>
/// GET/SET the button's style.
/// </summary>
[Category("Behavior")]
[Description("Indicates the button's style.")]
[DefaultValue(ButtonStyle.Simple)]
public ButtonStyle ButtonActionStyle

Even on parent controls that don't have Localizable=TRUE, the enum still
serializes to the .resx:

this._doneButton.ButtonActionStyle =
((Summit.Framework.View.ButtonStyle)(resources.GetObject("_doneButton.ButtonActionStyle")));

This just **shouldn't** be happening.

It becomes a problem, in that we start seeing lots of partial-bind
errors at runtime.

PROBLEM #2:

There is another related problem. We've found that you can't have an
enum defined in a Control based class and have it reliably serialize. I
can provide more information if needed.

Sean
 
S

Sean J Donovan

Thanks, that's only reference though.
It doesn't answer the question.

:-(

Sean

Sijin said:
Check out this link
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custcodegen.asp


and also these for related info
http://msdn.microsoft.com/msdnmag/issues/03/04/Design-TimeControls/default.aspx

http://msdn.microsoft.com/msdnmag/issues/03/05/Design-TimeControls/default.aspx

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vsnetpropbrow.asp


Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

When you have a control, and Localizable = FALSE, all child controls
serialize into the InitializeComponent method. There are some
exceptions, eg. Images have their value written into the .resx file.

Eg. this.label1.Location = new System.Drawing.Point(104, 64);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "Hello";

If you have a control that has Localizable = TRUE, when all child
controls are code-serialized, the actual values are typically written
to the .resx file.

Eg. this.label1.AccessibleDescription =
resources.GetString("label1.AccessibleDescription");
this.label1.AccessibleName =
resources.GetString("label1.AccessibleName");
this.label1.Anchor =
((System.Windows.Forms.AnchorStyles)(resources.GetObject("label1.Anchor")));



PROBLEM #1:

However, we have a case where the Localizable = FALSE, and the
properties are still in the .resx, IMHO, they shouldn't be, and it's a
bug. Has anyone else seen this?

Specifcally, we have a enum property, defined as:

/// <summary>
/// GET/SET the button's style.
/// </summary>
[Category("Behavior")]
[Description("Indicates the button's style.")]
[DefaultValue(ButtonStyle.Simple)]
public ButtonStyle ButtonActionStyle

Even on parent controls that don't have Localizable=TRUE, the enum
still serializes to the .resx:

this._doneButton.ButtonActionStyle =
((Summit.Framework.View.ButtonStyle)(resources.GetObject("_doneButton.ButtonActionStyle")));


This just **shouldn't** be happening.

It becomes a problem, in that we start seeing lots of partial-bind
errors at runtime.

PROBLEM #2:

There is another related problem. We've found that you can't have an
enum defined in a Control based class and have it reliably serialize.
I can provide more information if needed.

Sean
 

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

Similar Threads


Top