Object Disposed Exception in MyBase.Dispose() ??

blackduck603

Member
Joined
Sep 17, 2008
Messages
21
Location
NH
Programming Experience
3-5
I am getting the following Exception when calling MyBase.Dispose ()
ObjectDisposedException was unhandled.
I tried adding a Try Catch around the call but it doesn't catch the exception.

VB.NET:
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        Try '  NEW - TEST - CATCH EXCEPTION ON EXIT
            MyBase.Dispose(disposing)
        Catch ex As Exception
            MessageBox.Show(ex.GetType().FullName & " -" & ex.Message & " - " & ex.StackTrace, "CACMS", MessageBoxButtons.OK, MessageBoxIcon.Hand)
        End Try
    End Sub

FYI: The value of disposing is False


Any ideas?

Thanks,
Bill
 
did you check to see if the component.Dispose() was causing the error? Try putting a breakpoint in here and stepping through the code checking out the 2 objects that are disposing.
 
RE: did you check to see if the component.Dispose() was causing the error?

I did try that.
components.Dispose() is not getting executed (it is Nothing).
The last breakpoint before the Exception is the call to MyBase.Dispose(disposing)

I just found out that this is only happening on my PC out of 3 developers.
Any Dev System or environment settings that might be causing this?

Thanks
 
Figured it out !!!

This error was being caused by my IBM iSeries Access for Windows.
The exception was occurring in the Dispose() call of my Login Session which uses IBM.Data.DB2.iSeries.

I was using iSeries Version 5 Release 4, Service Pack SI20465.

IBM's Service Packs SI30707 and SI32972 address this issue.
I installed SI32972 and no longer get the Exception.

I do not have the specifics of the Patch Fix information but this Exception on Exit seems to have been addressed.

I hope that this helps someone in the future.
 
Here is the Patch Info from IBM

VB.NET:
[B]System.ObjectDisposedException using .NET Framework 2.0

Problem: [/B]
When using the IBM.Data.DB2.iSeries .NET provider with .NET Framework 2.0, 
an ObjectDisposedException occurs when the application terminates. 
This problem occurs because of an incompatible change made in the .NET Framework. 

The behavior of the property WaitHandle.Handle changed between .NET 1.1 and .NET 2.0. In .NET 1.1, 
raw handles are stored in the WaitHandle object, while .NET 2.0 wraps all raw handles with SafeWaitHandle. 
As a consequence, WaitHandle.Handle is being marked as obsolete when using the v2.0 framework. 
IBM.Data.DB2.iseries uses WaitHandle.Handle. 

As a result of opening a connection in the .NET v2.0 framework with the IBM.Data.DB2.iseries provider, 
the following exception occurs at application close: 


System.ObjectDisposedException was unhandled 
Message="Safe handle has been closed" 
Source="mscorlib" 
ObjectName="" 
StackTrace: 
at System.Runtime.InteropServices.SafeHandle.DangerousRelease() 
at System.Threading.RegisteredWaitHandleSafe.Finalize()  

[B]Resolution: [/B]
This problem is documented in APAR SE22506 and is corrected with the following service packs: 

V5R3 SI24723 
V5R4 SI26879 

http://www-01.ibm.com/support/docview.wss?uid=nas2e10cc831283be8e286257097003c83e1

FYI:
SI26879 is included in SI30707 and SI32972
 
Back
Top