U
Urs Eichmann
The following piece of code will run fine in .NET 1.1 without SP1, but
will throw a NullReferenceException in SP1. Sadly, our app no longer
runs with SP1, since it uses the same pattern (changing another row of
data inside a ListChanged event of a DataView).
Could please someone from Microsoft confirm this as a bug, and/or
provide a workaround?
Regards,
Urs
run the following as a console app:
[VB.NET]
Imports System.Data
Module Module1
Private dt As DataTable
Private b As Boolean
Sub Main()
dt = New System.Data.DataTable
dt.Columns.Add("Col1", GetType(String))
dt.Columns.Add("Col2", GetType(String))
Dim dv As New DataView(dt, "", "Col1",
DataViewRowState.CurrentRows)
AddHandler dv.ListChanged, AddressOf OnListchanged
Dim dv2 As New DataView(dt, "", "Col2",
DataViewRowState.CurrentRows)
AddHandler dv2.ListChanged, AddressOf OnListchanged
dt.Rows.Add(New Object() {"a", "b"}) ' NullRefException will be
thrown here
End Sub
Private Sub OnListchanged(ByVal s As Object, ByVal e As
System.ComponentModel.ListChangedEventArgs)
If b Then Return
b = True ' don't want recursive calling
dt.Rows.Add(New Object() {"c", "d"})
End Sub
End Module
will throw a NullReferenceException in SP1. Sadly, our app no longer
runs with SP1, since it uses the same pattern (changing another row of
data inside a ListChanged event of a DataView).
Could please someone from Microsoft confirm this as a bug, and/or
provide a workaround?
Regards,
Urs
run the following as a console app:
[VB.NET]
Imports System.Data
Module Module1
Private dt As DataTable
Private b As Boolean
Sub Main()
dt = New System.Data.DataTable
dt.Columns.Add("Col1", GetType(String))
dt.Columns.Add("Col2", GetType(String))
Dim dv As New DataView(dt, "", "Col1",
DataViewRowState.CurrentRows)
AddHandler dv.ListChanged, AddressOf OnListchanged
Dim dv2 As New DataView(dt, "", "Col2",
DataViewRowState.CurrentRows)
AddHandler dv2.ListChanged, AddressOf OnListchanged
dt.Rows.Add(New Object() {"a", "b"}) ' NullRefException will be
thrown here
End Sub
Private Sub OnListchanged(ByVal s As Object, ByVal e As
System.ComponentModel.ListChangedEventArgs)
If b Then Return
b = True ' don't want recursive calling
dt.Rows.Add(New Object() {"c", "d"})
End Sub
End Module