我通过加载类型库 (TLB) 并使用 ITypeLib
和 ITypeInfo
迭代类型来获取 COM 函数的地址。
调用 ITypeInfo 的 AddressOfMember
函数后,我遇到了以下异常:
System.Runtime.InteropServices.COMException (0x800288BD): Wrong module kind for the operation. (Exception from HRESULT: 0x800288BD (TYPE_E_BADMODULEKIND)) at System.Runtime.InteropServices.ComTypes.ITypeInfo.AddressOfMember(Int32 memid, INVOKEKIND invKind, IntPtr& ppv).
如何摆脱这个异常?
最佳答案
我不确定,以前没有做过这种事情,但你说你正在加载tlb文件?可能是addressofmember需要加载com对象的dll,我以为tlb文件只是接口(interface)的描述,addressofmember不会有任何代码加载。
关于c# - 为什么在获取 COM 函数的地址时发生异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2825074/