Exception from HRESULT: 0x80004002 (E_NOINTERFACE)

旧街凉风 提交于 2020-01-14 07:48:08

问题


I'm in charge of the maintenance of a C# application (VS 2005). This C# applications calls a dll ("mydll.dll"). I needed to make a few changes on the dll in question.

I have the file "mydll.vbp" that was written in Visual Basic 6.0. I made my changes in Visual Studio and, then, "made "mydll"" from the Visual Basic interface.

The problem is that, now, at each time I try to instance a class from "mydll.dll" in debbuger mode in C#, I have the following "InvalidCastException"

Unable to cast COM object of type mydll.ClassFrommydll to interface type mydll._ClassFrommydll'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{384FB79F-B636-4655-9441-8222692AB8AE}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

I tried to re-reference the dll in question ... but that does not change anything.

Any idea on what it could come from ?

Many many thanks to all of yopu who can help. Have been stuck with this problem for days now. Start to feel the pressure ...


回答1:


mark the main class [STAThread] and your problem will be solved




回答2:


I ran into this exact problem using the IBM Dll's.

[STAThread]
static void Main(string[] args)
{
}

Fixed the issue for me with all COM interfaces being usable and the exception cleared




回答3:


Remove all GUIDs and "ComVisible" attributes from the class, then switch the [assembly: ComVisible(true)] attribute in the AssemblyInfo-File to 'true'.



来源:https://stackoverflow.com/questions/9788135/exception-from-hresult-0x80004002-e-nointerface

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!