Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 1.1 VB.NET 代码中使用互操作 COM 程序集,当我尝试设置类的属性时,我收到一条InvalidCastException消息“QueryInterface for Interface ... failed”。
InvalidCastException
对此有什么想法吗?
首先,确保您的 COM 组件已使用 regsvr32.exe 注册。
然后,确保还注册了任何必要的编组支持——这些支持是以下两种之一:
1) 代理/存根 DLL,通常称为 <YourComponent>ps.dll -- 也使用 regsvr32.exe 注册它
2) 关联类型库 -- 使用 regtlib.exe 注册它
如果您在 DLL 上使用了 tlbimp,请尝试使用 regtlib 来注册 DLL 类型库。