IDispatch :: Invoke(..)异常错误 [英] IDispatch::Invoke(..) exception error

查看:113
本文介绍了IDispatch :: Invoke(..)异常错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...

我正在Windows ce平台(wince 5.0)中使用ATL/COM(vc ++)和c#编写程序.

ATL/COM具有ConnectionPoint&的功能.事件.
并为事件调用C#.

ATL/COM ----------------------------------------------- -------------

HRESULT Fire_OnGetAlarmState(BSTR inBstrEventID, 
                             BSTR * outBstrDate, 
                             BSTR * outBstrContent)
{
...
}
HRESULT Fire_OnGetResidentArrival(BSTR inBstrEventID, 
                                  BSTR * outBstrEntranceName, 
                                  BSTR * outBstrEntranceAddr, 
                                  BSTR * outBstrRelationShip)
{
...
}	


如果在C#中分别注册了关于两个事件的事件方法,则没有问题.
但是,如果两个事件方法在C#中注册,则ATL/COM中会出现问题.
问题是IDispatch :: Invoke(...)涉及的排他错误.

而且源代码在PC平台上完全没有问题.

你能告诉我如何解决这个问题吗?

解决方案

Hello heedong2.kim,

我想到的第一件事就是召集惯例.当我用Google搜索ATL/COM(vc ++)和c#的调用约定时,很明显这里就是这种情况.也许下面的文字可以帮助您解决此问题.祝你好运!

我找到的答案是:
要使用C#访问ATL COM dll,必须首先使用tlbimp命令或从Visual Studio添加引用"命令为该dll创建.NET包装类,然后使用浏览"选择dll.后者将自动创建.NET包装器并添加包装器的引用,在第一个选项之后,您将必须
再次执行添加参考部分,并使用浏览"按钮选择.NET代理.


这是原始帖子的链接 [ 解决方案

Hello heedong2.kim,

The first thing that came into my mind would be calling convention. When I googled the calling conventions for ATL/COM(vc++) and c# it was immediately clear that this is the case here. Maybe the text below can help you solve this problem. Good luck!

This answer I found:
To access an ATL COM dll in C#, you must first create the .NET wrapper class for that dll by either using tlbimp command or from the visual studio "Add reference" command and select the dll using Browse. The latter will automatically create the .NET wrapper and add the wrapper''s reference, where as after the first option, you will have to
again do the add reference part and select the .NET proxy using the Browse button.


This is the link to the original post[^]


这篇关于IDispatch :: Invoke(..)异常错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆