Creates a reference to the specified member of a type or module that is defined outside the current scope, and defines a token for that reference.
HRESULT DefineImportMember ( [in] IMetaDataAssemblyImport *pAssemImport, [in] const void *pbHashValue, [in] ULONG cbHashValue, [in] IMetaDataImport *pImport, [in] mdToken mbMember, [in] IMetaDataAssemblyEmit *pAssemEmit, [in] mdToken tkParent, [out] mdMemberRef *pmr );
The DefineImportMember method looks up the member, specified by mbMember, that is defined in another scope, specified by pImport, and retrieves its properties. It uses this information to call the IMetaDataEmit::DefineMemberRef method in the current scope to create the member reference.
Generally, before you use the DefineImportMember method, you must create, in the current scope, a type reference or module reference for the target member's parent class, interface, or module. The metadata token for this reference is then passed in the tkParent argument. You do not need to create a reference to the target member's parent if it will be resolved later by the compiler or linker. To summarize:
If the target member is a field or method, use either the IMetaDataEmit::DefineTypeRefByName or the IMetaDataEmit::DefineImportType method to create a type reference, in the current scope, for the member's parent class or parent interface.
If the target member is a global variable or global function (that is, not a member of a class or interface), use the IMetaDataEmit::DefineModuleRef method to create a module reference, in the current scope, for the member's parent module.
If the target member's parent will be resolved later by the compiler or linker, then pass mdTokenNil in tkParent. The only scenario in which this applies is when a global function or global variable is being imported from a .obj file that will ultimately be linked into the current module and the metadata merged.
Platforms: See .NET Framework System Requirements.
Library: Used as a resource in MSCorEE.dll
.NET Framework Versions: 4.5, 4, 3.5 SP1, 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0, 1.1, 1.0