VS2005's Auto creation of an Xml document for parameter value

In a windows form, I have a control with a public XmlDocument property. Every so often (when the designer code changes), Visual Studio 2005 adds an XmlDocument to the form as well as this code (names have been changed to protect the innocent) in the InitializeComponent() method:

xmlDocument1.InnerText = "";
xmlDocument1.InnerXml = resources.GetString(
"xmlDocument1.InnerXml"
);
xmlDocument1.Prefix =
""
;
xmlDocument1.PreserveWhitespace =
false
;
xmlSchemaCompilationSettings1.EnableUpaCheck =
true
;
xmlSchemaSet1.CompilationSettings = xmlSchemaCompilationSettings1;
xmlDocument1.Schemas = xmlSchemaSet1;
xmlDocument1.Value =
null
;
this.theUserControl.ThePublicXmlProperty = xmlDocument1;

This code throws an exception when setting the InnerText (the first line above). This issue precludes opening the form in design mode or as part of the application flow (an object reference error is produced).

I can remove this code myself and all is well. But when I change something in designer it comes back.

Is there any way to mark a public property as “I don't care if it's null or not” so VS2005 will just ignore it? I am ensuring that it's set before accessing it.

Or--is there a way to tweak this code insertion in the IDE?

Print | posted @ Thursday, December 22, 2005 5:11 PM

Comments on this entry:

No comments posted yet.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: