在VB.NET或C#中调用COM组件多事件出错

ad4017 2008-08-21 12:49:44
在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
...全文
284 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
guoyanchun1983 2009-03-02
  • 打赏
  • 举报
回复
在网上找着很多也说这个问题的,而且是英文的,好像都是在调用由delphi写的ocx时发生的
tweeger 2009-03-02
  • 打赏
  • 举报
回复
关注一下
guoyanchun1983 2009-03-02
  • 打赏
  • 举报
回复
我的是第三个引用时出现这个问题,用的C#
ad4017 2008-08-23
  • 打赏
  • 举报
回复
UP
ad4017 2008-08-21
  • 打赏
  • 举报
回复
UP
LQknife 2008-08-21
  • 打赏
  • 举报
回复
那就顶了,看不懂
ad4017 2008-08-21
  • 打赏
  • 举报
回复
进来看的有奖,帮顶的有分
ad4017 2008-08-21
  • 打赏
  • 举报
回复
没人会啊,急!在线等
ad4017 2008-08-21
  • 打赏
  • 举报
回复
这么快就掉下去了,自己顶
优途科技 2008-08-21
  • 打赏
  • 举报
回复
不懂VB帮顶把!

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧