A null ArrayList member is initialized to a zero length ArrayList class after it is deserialized (815105)
The information in this article applies to:
- Microsoft .NET Framework 1.0
- Microsoft Windows .NET Framework 1.1
- Microsoft Visual C# .NET (2002)
- Microsoft Visual C# .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual Basic .NET (2003)
Beta InformationThis article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.
No formal product support is available from Microsoft for this Beta product. For information about how to obtain support for a Beta release, see the documentation that is included with the Beta product files, or check the Web location where you downloaded the release.SYMPTOMSWhen you serialize an object that contains a null ArrayList class object as a public member, as expected the tags for the ArrayList class member
is not present in the serialized XML file. However, after deserialization, you may notice that the
ArrayList class instance is not null. Instead, the ArrayList class member is initialized to
a zero length ArrayList class.CAUSEThe XML Serializer initializes all the public field members of the serialized class
during deserialization. Therefore, the ArrayList class member is initialized to a zero
length ArrayList.WORKAROUNDTo work around this problem, modify the ArrayList
class instance as null after deserialization. To do this, add the
following line of code after deserialization: Microsoft Visual C# .NET code:// Make an ArrayList instance as null after deserialization.
obj.MyArrayList = null; Microsoft Visual Basic .NET code:' Make an ArrayList instance as null after deserialization.
obj.MyArrayList = Nothing STATUS This
behavior is by design.REFERENCES
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
314150
INFO: Roadmap for XML Serialization in the .NET Framework
Modification Type: | Major | Last Reviewed: | 2/5/2004 |
---|
Keywords: | kbNameSpace kbCollections kbXML kbprb KB815105 kbAudDeveloper |
---|
|