L
lawrence.anstey
We have a program that has been in development for a number of years
now, and it has created a fairly sizable startup routine that, on
occasion, throws an ObjectDisposedException. We are logging the error,
but it seems to occur at different places every time. In other words,
it is difficult to debug.
The main problem is that the ObjectName property of the
ObjectDisposedException is always an empty string, as this VB.NET
example:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Try
Dim Test As New Button
Test.Name = "ObjectTest"
Test.Text = "Not yet disposed"
Test.Dispose()
System.GC.Collect()
Test.Text = "This object is disposed"
MessageBox.Show(Test.Text)
Catch ObEx As ObjectDisposedException
MessageBox.Show(ObEx.ObjectName)
End Try
End Sub
This always throws the ObjectDisposedException, and the name is always
a blank string. If the code is run in .NET full, then the ObjectName
is "ObjectTest". Is this something we are doing wrong? Does anyone
have any pointers as to a better way we can try to find this exception?
now, and it has created a fairly sizable startup routine that, on
occasion, throws an ObjectDisposedException. We are logging the error,
but it seems to occur at different places every time. In other words,
it is difficult to debug.
The main problem is that the ObjectName property of the
ObjectDisposedException is always an empty string, as this VB.NET
example:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Try
Dim Test As New Button
Test.Name = "ObjectTest"
Test.Text = "Not yet disposed"
Test.Dispose()
System.GC.Collect()
Test.Text = "This object is disposed"
MessageBox.Show(Test.Text)
Catch ObEx As ObjectDisposedException
MessageBox.Show(ObEx.ObjectName)
End Try
End Sub
This always throws the ObjectDisposedException, and the name is always
a blank string. If the code is run in .NET full, then the ObjectName
is "ObjectTest". Is this something we are doing wrong? Does anyone
have any pointers as to a better way we can try to find this exception?