在VB.NET或C#中调用COM组件多事件出错
在VB中引入COM组件,响应单个COM事件不出错,响应两个COM事件就出现"Exception from HRESULT: 0x80040202"错误,如何解决,请高手帮助.代码如下:
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.IO
Public Class Form1
Private WithEvents ff As SService'(COM组件名称)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ff = New SService
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ff.SendMessage("你好")'调用COM组件方法
End Sub
Private Sub ff_OnMessageChange(ByVal ID As String, ByVal PMessage As String) Handles ff.OnMessageChange 'COM组件事件
'未写处理代码
End Sub
Private Sub ff_OnStatusChanged(ByVal Status As Integer, ByVal ErrorStatus As Integer) Handles ff.OnStatusChanged 'COM组件另一事件
MsgBox("事件执行!")
End Sub
End Class