I am developing a COM library that exposes a single class Number and uses
the ComClass attribute. I have also added another project that I use to
debug the COM class. I recently added several events to the COM class which
are raised asynchronously. The following code will execute with no
problems; however, as soon as I add an event handler to the debug program, I
get the error:
An unhandled exception of type 'System.MethodAccessException' occurred in
VB7Debug.exe
Additional information: AsyncBeginEventHandler..ctor(System.Object, IntPtr)
This code works without an event handler defined.
Private WithEvents num As NumberString.Number
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Try
num = New NumberString.Number
With PNum1
CallAMethod
End With
Catch ex As SystemException
Stop
Catch ex As Exception
Stop
End Try
End Sub
When this is added to the debug application, I get the above error.
Private Sub num_AsyncBegin(ByVal sender As Object, ByVal e As
System.EventArgs) Handles num.AsyncBegin
End Sub
The constructor of my COM class is actually being executed. Once the thread
returns from the constructor, the error is immediately raised.
Thanks in advance