ICorProfilerInfo2::GetFunctionFromTokenAndTypeArgs Method

Gets the FunctionID of a function by using the specified metadata token, containing class, and ClassID values of any type arguments.


HRESULT GetFunctionFromTokenAndTypeArgs(  
    [in] ModuleID moduleID,  
    [in] mdMethodDef funcDef,  
    [in] ClassID classId,  
    [in] ULONG32 cTypeArgs,  
    [in, size_is(cTypeArgs)] ClassID typeArgs[],  
    [out] FunctionID* pFunctionID);  


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

[in] An mdMethodDef metadata token that references the function.

[in] The ID of the function's containing class.

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

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

[out] A pointer to the FunctionID of the specified function.


Calling the GetFunctionFromTokenAndTypeArgs method with an mdMethodRef metadata instead of an mdMethodDef metadata token can have unpredictable results. Callers should resolve the mdMethodRef to an mdMethodDef when passing it.

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

In general, use of GetFunctionFromTokenAndTypeArgs is discouraged. If profilers are interested in events for a particular function, they should store the ModuleID and mdMethodDef of that function, and use ICorProfilerInfo2::GetFunctionInfo2 to check whether a given FunctionID is that of the desired function.


Platforms: See System Requirements.

Header: CorProf.idl, CorProf.h

Library: CorGuids.lib

.NET Framework Versions: Available since 2.0

See also