Windows Server 2008 中 COM 对象的 InvalidCastException
本文关键字:对象 InvalidCastException COM Server 2008 Windows | 更新日期: 2023-09-27 18:32:08
我有一个站点与Windows Server 2008(x64版本)上部署在IIS7上的C#服务进行通信的站点。该服务正在尝试从第三方 dll 访问 COM 对象。执行此操作时,将引发以下形式的异常:
System.InvalidCastException: Unable to cast COM object of type 'MyClass' to interface type 'TheirInterface'.
This operation failed because the QueryInterface call on the COM component for the interface with IID '{88B11E8A-0B27-459C-BC28-A4D4113FD4AE}' failed due
to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
我在Windows 7上运行的许多其他计算机上托管了相同的站点,因此我认为问题与操作系统(Windows Server 2008)有关。关于我可以搜索此异常的解决方案的任何建议,或者是否应该在 IIS 上进行任何配置?
您需要将
网站作为 32 位网站运行,或者使用针对 x64 平台编译的 COM 对象。换句话说,无法加载 COM 对象,因为它仅支持由 32 位进程加载。