简体   繁体   English

为什么我从C#应用程序调用VB6 ActiveX DLL失败并显示“不支持此类接口”?

[英]Why does my call to a VB6 ActiveX DLL from C# app fail with “No such interface supported”?

I have a VB6 Active DLL that I'm trying to call from C#. 我有一个试图从C#调用的VB6活动DLL。

I've converted it using tblimp and imported it into VS 2010. 我已经使用tblimp对其进行了转换,并将其导入了VS 2010。

I then instantiate it using: 然后,我使用以下方法实例化它:

AppWebActiveX.Users appWebActiveX = new appWebActiveX.Users();

There's a Users interface and a UsersClass class when I look in the object browser. 当我在对象浏览器中查看时,有一个Users界面和一个UsersClass类。

Then I call: 然后我打电话给:

bool isExistingUser = appWebActiveX.IsExistingUser("cat");

bool IsExisting(string) is a valid method, according to the object browser. 根据对象浏览器, bool IsExisting(string)是有效方法。

However, this returns: 但是,这返回:

Unable to cast COM object of type 'AppWebActiveX.UsersClass' to interface type 'AppWebActiveX._Users'. 无法将类型为“ AppWebActiveX.UsersClass”的COM对象转换为接口类型为“ AppWebActiveX._Users”。 ... No such interface supported ... ...不支持这种接口...

The latest stack call is to System.StubHelpers.StubHelpers.GetCOMIPFromRCW. 最新的堆栈调用是对System.StubHelpers.StubHelpers.GetCOMIPFromRCW的调用。

I'm running the app on Windows Server 2003 Standard Edition (x86 - 32bit) and it's a 32-bit DLL. 我正在Windows Server 2003 Standard Edition(x86-32位)上运行该应用程序,它是32位DLL。 I'm making the call from a C# console app. 我正在从C#控制台应用程序拨打电话。

Any advice? 有什么建议吗?

原来,我从main方法中省略了[STAThread]属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM