Degradation occurs when you try to serialize and deserialize 32-bit icons (814735)
The information in this article applies to:
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft .NET Framework 1.0
- Microsoft .NET Framework 1.1
SYMPTOMSWhen you try to serialize 32-bit icons to a file, you try to
deserialize the icons from that file, and then you try to display the icons,
there may be degradation in the icons. The colors are not displayed correctly
or there is a corrupted background behind the icons.WORKAROUNDTo work around this problem, add the icons to an
ImageList control, and then directly serialize the ImageList control. To do this, follow these steps:
- Add a TreeView control to Form1, and then
add an ImageList control to Form1.
- Add a 32-bit icon to the ImageList1
control.
Note Make sure you set the ImageSize property to
32 ,32. - Bind ImageList1 to the
ImageList property of the TreeView control in
the Properties window.
- Replace the code in the Button1_Click
event handler with the following code:
Try
TreeView1.ImageList = ImageList1
Dim oStream As Stream = File.Create("D:\Test1.dat")
Dim oSerializer As BinaryFormatter = New BinaryFormatter
oSerializer.Serialize(oStream, TreeView1.ImageList.ImageStream)
oStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try - Replace the code in the Button2_Click
event handler with the following code:
Try
Dim oStream As Stream = File.OpenRead("D:\Test1.dat")
Dim oDeSerializer As BinaryFormatter = New BinaryFormatter
Dim Il As ImageList = New ImageList
Il.ImageStream = CType(oDeSerializer.Deserialize(oStream), ImageListStreamer)
ImageList1 = Il
oStream.Close()
TreeView1.ImageList = ImageList1
TreeView1.Nodes.Clear()
Dim count as Integer
For count = 0 To ImageList1.Images.Count - 1
Dim n As TreeNode = New TreeNode("Test " & count, count, count)
TreeView1.Nodes.Add(n)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are
listed at the beginning of this article.
REFERENCESFor more information about how to implement serialization by
using the BinaryFormatter class, visit the following Microsoft Developer Network (MSDN) Web
site:
Modification Type: | Minor | Last Reviewed: | 1/24/2006 |
---|
Keywords: | kbvs2005swept kbvs2005doesnotapply kbvs2002sp1sweep kberrmsg kbWindowsForms kbbug KB814735 kbAudDeveloper |
---|
|