Article ID: 310827 - Last Review: January 18, 2006 - Revision: 2.1

A Probe function that is injected by profiler may cause unhandled exception in Visual C++

This article was previously published under Q310827
Expand all | Collapse all

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) )
				

STATUS

This behavior is by design.

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
309551  (http://support.microsoft.com/kb/309551/EN-US/ ) INFO: CLR Profiling Services Problems

APPLIES TO
  • Microsoft Visual C++ .NET 2002 Standard Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ 2005 Express Edition
Keywords: 
kbtshoot kbperformancetool kbprb KB310827
 

Article Translations