Occasionally my application crashes....
I have captured the crash using WinDbg, and the Exception trace is:
Exception object: 026c18ac
Exception type: System.InvalidOperationException
Message: Handle is not initialized.
InnerException: <none>
StackTrace (generated):
SP IP Function
00E5FAE8 66D30A4E mscorlib_ni!System.Runtime.InteropServices.GCHandle.Free()+0x93679e
00E5FAFC 075EC9C4 UNKNOWN!NAudio.Wave.Compression.AcmStreamHeader.Dispose(Boolean)+0x24
00E5FB08 075FBCE8 UNKNOWN!NAudio.Wave.Compression.AcmStreamHeader.Finalize()+0x18
Obviously one or more of the GCHandles has already been freed, but I have looked over the code for AcmStreamHeader and cannot see how this can occur - the Dispose() methods appear to handle being called twice, and attempt to prevent this happening. I'm not sure why the GC.SuppressFinalize(this), and Dispose(true); are ordered as they are (in Dispose()) - as this is not the normal recommendation.
My only thought is that the Garbage collector has some kind of parallelism that is allow the Finalizer to run despite the fact that Dispose() is active too?
I have captured the crash using WinDbg, and the Exception trace is:
Exception object: 026c18ac
Exception type: System.InvalidOperationException
Message: Handle is not initialized.
InnerException: <none>
StackTrace (generated):
SP IP Function
00E5FAE8 66D30A4E mscorlib_ni!System.Runtime.InteropServices.GCHandle.Free()+0x93679e
00E5FAFC 075EC9C4 UNKNOWN!NAudio.Wave.Compression.AcmStreamHeader.Dispose(Boolean)+0x24
00E5FB08 075FBCE8 UNKNOWN!NAudio.Wave.Compression.AcmStreamHeader.Finalize()+0x18
Obviously one or more of the GCHandles has already been freed, but I have looked over the code for AcmStreamHeader and cannot see how this can occur - the Dispose() methods appear to handle being called twice, and attempt to prevent this happening. I'm not sure why the GC.SuppressFinalize(this), and Dispose(true); are ordered as they are (in Dispose()) - as this is not the normal recommendation.
My only thought is that the Garbage collector has some kind of parallelism that is allow the Finalizer to run despite the fact that Dispose() is active too?