unable to handle exception thrown after dispose?

M

matt.arens

here is some background:

I am using the MQSeries/Websphere .Net classes provided by Microsoft.
The Websphere Windows Client software is required in order to use the
..Net classes. However, I would like to warn users that they need this
software, otherwise they will get a TypeInitializationException ("The
type initializer for 'IBM.WMQ.MQTrace' threw an exception.").

Here is my code to catch that in the form load event:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

MQEnvironment.Hostname = "x"
MQEnvironment.Port = "x"
MQEnvironment.Channel = "x"
Dim qmgr As MQQueueManager

Try
qmgr = New MQQueueManager("x")
Catch ex As System.TypeInitializationException
MsgBox("an exception occurred. You probably need to
install the MQSeries client software.")
End Try
End Sub

This seems to work ok.

However, the same TypeInitializationException is thrown when I close my
app, and I can't seem to find a way to catch it.

I also tried catching it after calling dispose, but that didn't help
either:

Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Try
MyBase.Dispose(disposing)
Catch ex As System.TypeInitializationException
MsgBox("an exception occurred.")
End Try
End Sub

The exception occurs sometime after Dispose is called, and I am unable
to catch it.

Here is the stack trace:

at IBM.WMQ.MQTrace.Trace(UInt32 component, UInt32 module, String
traceText)
at IBM.WMQ.MQBaseObject.Trace(UInt32 module, String traceText)
at IBM.WMQ.MQQueueManager.Finalize()

The debugger offers me this after the error is thrown, in case this is
important:

Disassembly:

00000000 push esi
00000001 push eax
00000002 mov dword ptr [esp],ecx
00000005 mov esi,edx
00000007 cmp dword ptr ds:[01101FBCh],0
0000000e je 00000015
00000010 call 7942EABE
00000015 push dword ptr [esp+0Ch]
00000019 mov edx,esi
0000001b mov ecx,2Ch
00000020 call dword ptr ds:[011041C0h]
00000026 nop
00000027 nop
00000028 pop ecx
00000029 pop esi
0000002a ret 4

Thanks.
 
M

matt.arens

I am using the MQSeries/Websphere .Net classes provided by Microsoft.

err... I mean to say provided by IBM.

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top