Why Exception occured getting address of COM function?

3

I am getting the address of a COM function by loading type library (TLB) and iterating over types using ITypeLib and ITypeInfo. After calling the AddressOfMember function of ITypeInfo I am facing the following exception:

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

How do I get rid of this exception?

c#
com
interop
vtable
typelib
asked on Stack Overflow May 13, 2010 by Usman • edited Nov 25, 2014 by VividD

1 Answer

1

I'm not sure, haven't done this type of thing before, but you say you are loading the tlb file? It might be that for addressofmember you need to load the dll that contains the com object, I thought the tlb file was just a description of the interfaces, and thus addressofmember wouldn't have any code to load.

answered on Stack Overflow Feb 15, 2011 by Dan OConnell

User contributions licensed under CC BY-SA 3.0