ICorProfilerInfo2::GetClassFromTokenAndTypeArgs Method

Gets the ClassID of a type by using the specified metadata token and the ClassID values of any type arguments.


HRESULT GetClassFromTokenAndTypeArgs(  
    [in] ModuleID moduleID,  
    [in] mdTypeDef typeDef,  
    [in] ULONG32 cTypeArgs,  
    [in, size_is(cTypeArgs)] ClassID typeArgs[],  
    [out] ClassID* pClassID);  


[in] The ID of the module in which the type resides.

[in] An mdTypeDef metadata token that references the type.

[in] The number of type parameters for the given type. This value must be zero for non-generic types.

[in] An array of ClassID values, each of which is an argument of the type. The value of typeArgs can be NULL if cTypeArgs is set to zero.

[out] A pointer to the ClassID of the specified type.


Calling the GetClassFromTokenAndTypeArgs method with an mdTypeRef instead of an mdTypeDef metadata token can have unpredictable results; callers should resolve the mdTypeRef to an mdTypeDef when passing it.

If the type is not already loaded, calling GetClassFromTokenAndTypeArgs will trigger loading, which is a dangerous operation in many contexts. For example, calling this method during loading of modules or other types could lead to an infinite loop as the runtime attempts to circularly load things.

In general, use of GetClassFromTokenAndTypeArgs is discouraged. If profilers are interested in events for a particular type, they should store the ModuleID and mdTypeDef of that type, and use ICorProfilerInfo2::GetClassIDInfo2 to check whether a given ClassID is that of the desired type.


Platforms: See System Requirements.

Header: CorProf.idl, CorProf.h

Library: CorGuids.lib

.NET Framework Versions: Available since 2.0

See also