简体   繁体   中英

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#.

I've converted it using tblimp and imported it into 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.

Then I call:

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

bool IsExisting(string) is a valid method, according to the object browser.

However, this returns:

Unable to cast COM object of type 'AppWebActiveX.UsersClass' to interface type 'AppWebActiveX._Users'. ... No such interface supported ...

The latest stack call is to System.StubHelpers.StubHelpers.GetCOMIPFromRCW.

I'm running the app on Windows Server 2003 Standard Edition (x86 - 32bit) and it's a 32-bit DLL. I'm making the call from a C# console app.

Any advice?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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