bugs in .NETCF SP2
From: Frank Lamers (nomail)
Date: 03/10/04
- Next message: Daniel Moth: "Localisation by updating exe only (not the resources.dlls)"
- Previous message: Frank Lamers: "Re: Bug in TreeView"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 10 Mar 2004 11:21:09 +0100
Hi,
I found some bugs in the .NET compact framework. All the problems are not
solved by SP2. For some of them I found a workaround, but for others I
still look for. Maybe you can help.
The first two bugs we discussed here already. I just added them for
completeness. In the end of this posting I added a sample code to verify.
Step through and look at the comments in the code.
Thanks for ideas how to solve the problems.
--Frank
****** list ******
Bugs in .NET Compact Framework 1.1:
1: System.Windows.Forms.TreeView after calling .Clear the property
.SelectedNode is still set
Treeview.SelectedNode is still pointing to a treenode (the last node in the
treeview before clearing it)
Workaround: Set the Selectednode to nothing before calling Clear
2: System.Windows.Forms.TreeView.SelectedNode cannot be set to nothing
Treeview.SelectedNode cannot be set to nothing after calling Clear of the
treeview (and Bug 1 occurs)
Workaround: You must set the SelectedNode to nothing BEFORE calling Clear or
create a new treenode and set SelectedNode to the new treenode
3: XmlDocument.CreateNode(XmlNodeType, String, String) specifying a
namespace as third parameter creating an element node will set the
namespaceURI, but no 'xmlns' attribute is added (after save and load the
attribute exists)
A namespaceURI in the XMLnode is created, but no 'xmlns' attribute is added.
This is contrary to W3C spec.
Workaround: Save the XMLDocument and reload it. Then the attribute exists.
4a: XmlDocument.CreateNode(XmlNodeType, String, String) creating an
attribute node and specifying a namespace without prefix, but adds
automatically a prefix in the XmlNode.OuterXml property (i.e. d0p1). The
XmlDocument.OuterXml gives a different prefix (i.e. d2p1)
4b: XmlDocument.CreateAttribut(String, String) same behavior as above
The attribute node has the NamespaceURI as given (without prefix), but the
OuterXML of XMLnode and XMLDocument add a prefix - different prefixes(!)
5a: XmlDocument.CreateNode(XmlNodeType, String, String) creating an
attribute node always throws exception if second parameter is 'xmlns'
(illegal namespace)
5b: XmlDocument.CreateAttribut(String, String) same behavior as above
5c: XmlDocument.CreateAttribut(String) same behavior as above
Creating an attribute with name 'xmlns' throws an exception. It is not
possible to create a xmlns-Attribute manually.
6a: XmlDocument.CreateNode(XmlNodeType, String, String) creating an
attribute node with qualified name (ns:name) set the name qualified, but the
OuterXml property just uses the localname without prefix. Prefix gets lost
during save.
6b: XmlDocument.CreateAttribut(String, String) same behavior as above
6c: XmlDocument.CreateAttribut(String) same behavior as above
The Attribute is created with a qualified name, localname and prefix are ok,
but OuterXML just uses localname (without prefix). Namespace prefix gets
lost during save.
7: XmlDocument.CreateNode(XmlNodeType, String, String) creating an element
node with qualified name (ns:name) sets the name qualified, but the OuterXml
property just uses the localname without prefix. Prefix gets lost during
save.
The Node is created with a qualified name, localname and prefix are ok, but
OuterXML just uses localname (without prefix). Namespace prefix gets lost
during save.
****** sample ******
Imports System.Xml
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents TreeView1 As System.Windows.Forms.TreeView
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Private Sub InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.TreeView1 = New System.Windows.Forms.TreeView
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
'
'TreeView1
'
Me.TreeView1.ImageIndex = -1
Me.TreeView1.Location = New System.Drawing.Point(8, 16)
Me.TreeView1.SelectedImageIndex = -1
Me.TreeView1.Size = New System.Drawing.Size(144, 48)
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(168, 24)
Me.Button1.Size = New System.Drawing.Size(56, 32)
Me.Button1.Text = "Select"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(168, 80)
Me.Button2.Size = New System.Drawing.Size(56, 32)
Me.Button2.Text = "XML"
'
'Form1
'
Me.ClientSize = New System.Drawing.Size(234, 270)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TreeView1)
Me.Menu = Me.MainMenu1
Me.Text = "Form1"
End Sub
#End Region
'Bugs in .NET Compact Framework 1.1:
'1: System.Windows.Forms.TreeView after calling .Clear the property
.SelectedNode is still set
'2: System.Windows.Forms.TreeView.SelectedNode cannot be set to nothing
'3: XmlDocument.CreateNode(XmlNodeType, String, String) specifying a
namespace as third parameter creating an element node will set the
namespaceURI, but no 'xmlns' attribute is added (after save and load the
attribute exists)
'4a: XmlDocument.CreateNode(XmlNodeType, String, String) creating an
attribute node and specifying a namespace without prefix, but adds
automatically a prefix in the XmlNode.OuterXml property (i.e. d0p1). The
XmlDocument.OuterXml gives a different prefix (i.e. d2p1)
'4b: XmlDocument.CreateAttribut(String, String) same behavior as above
'5a: XmlDocument.CreateNode(XmlNodeType, String, String) creating an
attribute node always throws exception if second parameter is 'xmlns'
(illegal namespace)
'5b: XmlDocument.CreateAttribut(String, String) same behavior as above
'5c: XmlDocument.CreateAttribut(String) same behavior as above
'6a: XmlDocument.CreateNode(XmlNodeType, String, String) creating an
attribute node with qualified name (ns:name) set the name qualified, but the
OuterXml property just uses the localname without prefix. Prefix gets lost
during save.
'6b: XmlDocument.CreateAttribut(String, String) same behavior as above
'6c: XmlDocument.CreateAttribut(String) same behavior as above
'7: XmlDocument.CreateNode(XmlNodeType, String, String) creating an
element node with qualified name (ns:name) sets the name qualified, but the
OuterXml property just uses the localname without prefix. Prefix gets lost
during save.
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim tn As TreeNode
tn = TreeView1.Nodes.Add("Newnode")
TreeView1.SelectedNode = tn
TreeView1.Nodes.Clear()
'!!! Bug 1: Treeview1.SelectedNode is still pointing to a treenode
MsgBox("SelectedNode:" & TreeView1.SelectedNode.Text, , "-Bug 1-")
'Workaround: Set the Selectednode to nothing before calling Clear
TreeView1.SelectedNode = Nothing
'!!! Bug 2: Treeview1.SelectedNode cannot be set to nothing
MsgBox("SelectedNode:" & TreeView1.SelectedNode.Text, , "-Bug 2-")
'Workaround: You must set the SelectedNode to nothing BEFORE calling
Clear or create a new treenode and set SelectedNode to the new treenode
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim xd As New XmlDocument
Dim xroot As XmlNode
Dim xn As XmlNode
'!!! Bug 3
xroot = xd.CreateNode(XmlNodeType.Element, "root", "http://myns")
xd.AppendChild(xroot)
' A namespaceURI in the XMLnode is created, but no 'xmlns' attribute
is added. This is contrary to W3C spec.
MsgBox("Document: " & xd.OuterXml, , "-Bug 3-")
MsgBox("Node Attributes: " & xroot.Attributes.Count, , "-Bug 3-")
'Workaround: Save the XMLDocument and reload it. Then the attribute
exists.
'******************************************************************
'!!! Bug 4a and b
xn = xd.CreateNode(XmlNodeType.Attribute, "myattr1", "http://myns")
'xn = xd.CreateAttribute("myattr1", "http://myns")
xroot.Attributes.SetNamedItem(xn)
' The attribute node has the NamespaceURI as given, but the OuterXML
of XMLnode and XMLDocument add a prefix - different prefixes !
MsgBox("Node OuterXML: " & xn.OuterXml, , "-Bug 4-")
MsgBox("Document OuterXML: " & xd.OuterXml, , "-Bug 4-")
'******************************************************************
'!!! Bug 5a and b and c
Try
xn = xd.CreateNode(XmlNodeType.Attribute, "xmlns", "")
'xn = xd.CreateAttribute("xmlns", "")
'xn = xd.CreateAttribute("xmlns")
Catch ex As Exception
MsgBox("Exception:" & vbCrLf & ex.Message, , "-Bug 5-")
End Try
' Creating an attribute with name 'xmlns' throws an exception. It is
not possible to create a xmlns-Attribute.
'******************************************************************
'!!! Bug 6a and b and c
xn = xd.CreateNode(XmlNodeType.Attribute, "d1p1:myattr2", "")
'xn = xd.CreateAttribute("d1p1:myattr2", "")
'xn = xd.CreateAttribute("d1p1:myattr2")
xroot.Attributes.SetNamedItem(xn)
' The Attribute is created with a qualified name, localname and
prefix are ok, but OuterXML just uses localname (without prefix). Namespace
prefix gets lost during save.
MsgBox("Node name: " & xn.Name, , "-Bug 6-")
MsgBox("Node OuterXML: " & xn.OuterXml, , "-Bug 6-")
'******************************************************************
'!!! Bug 7
xn = xd.CreateNode(XmlNodeType.Element, "d1p1:mynode1", "")
xroot.AppendChild(xn)
' The Node is created with a qualified name, localname and prefix
are ok, but OuterXML just uses localname (without prefix). Namespace prefix
gets lost during save.
MsgBox("Node name: " & xn.Name, , "-Bug 7-")
MsgBox("Node OuterXML: " & xn.OuterXml, , "-Bug 7-")
End Sub
End Class
- Next message: Daniel Moth: "Localisation by updating exe only (not the resources.dlls)"
- Previous message: Frank Lamers: "Re: Bug in TreeView"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|