Usman
Usman

Reputation: 2890

Why Exception occured getting address of COM function?

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?

Upvotes: 3

Views: 356

Answers (1)

Dan OConnell
Dan OConnell

Reputation: 217

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.

Upvotes: 1

Related Questions