A Probe function that is injected by profiler may cause unhandled exception in Visual C++ (310827)
The information in this article applies to:
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
- Microsoft Visual C++ 2005 Express Edition
This article was previously published under Q310827 SYMPTOMS If the injection probe function's metadata does not set the
miPreserveSig flag through IMetaDataEmit::DefineMethod(), the profiled application might throw unhandled exceptions.
CAUSE By default, the DefineMethod() call "mangles" the function signature to do the HRESULT
conversion. If the probe function does not return "HRESULT", the resulting
mismatch may cause the application that is being profiled to fail.
RESOLUTION To avoid this problem, use the miPreserveSig flag when you use IMetaDataEmit::DefineMethod() to inject a probe function. For example:
(pModuleInfo->m_pEmit)->DefineMethod( mdTokenNil,
L"ILCoverFunc",
mdPublic|mdStatic|mdPinvokeImpl,
rgSig,
sizeof( rgSig ),
0,
miIL | miPreserveSig, // NOTE THE miPreserveSig.
&(pModuleInfo->m_tkProbe) )
STATUSThis
behavior is by design.REFERENCESFor additional information, click the
article number below to view the article in the Microsoft Knowledge Base: 309551 INFO: CLR Profiling Services Problems
Modification Type: | Minor | Last Reviewed: | 1/18/2006 |
---|
Keywords: | kbtshoot kbPerformanceTool kbprb KB310827 kbAudDeveloper |
---|
|