ICorProfilerCallback learning : Please help get me started  
Author Message
Rob Bowman





PostPosted: Building Development and Diagnostic Tools for .Net, ICorProfilerCallback learning : Please help get me started Top

Hi everyone,

I would like to experiment with and learn about ICorProfilerCallback2 using the express edition(s) and/or the platform sdk. Can this be done and, if so, are there any "getting started" guides

My c++ skills are very rusty, so I would prefer to work in c#, but am I correct in thinking that an in-process com server simply can't be developed in visual c# 2005 express

I am willing to put the hours in to learn this advanced topic, but finding where to start is difficult. Any help would be much appreciated.

Please don't tell me I need visual studio pro as I can't afford to buy it at the moment!



.NET Development24  
 
 
David Broman - MSFT





PostPosted: Building Development and Diagnostic Tools for .Net, ICorProfilerCallback learning : Please help get me started Top

Hi, Rob. Not sure if VC# 2005 allows creation of an inproc COM server written in C#, but it doesn't really matter regarding profiling--you need to write your profiler in C++. The profiler is called by the runtime at very delicate points during execution of the profiled application, and it is often extremely unsafe to be running managed code at those points.

A good way to get started is to read through MSDN's CLR documentation, MSDN articles, and corprof.idl. Here are some starting points:

CLR Documentation for the latest profiling API:
http://msdn2.microsoft.com/en-us/library/ms404386.aspx

Intro, how-to articles
http://msdn.microsoft.com/msdnmag/issues/01/12/hood/default.aspx
http://msdn.microsoft.com/msdnmag/issues/01/11/NetProf/default.aspx

An article that introduces high-level wrapper classes to make profiling development easier
http://msdn.microsoft.com/msdnmag/issues/06/04/NETProfiling/default.aspx

You can find more advanced articles by searching MSDN for CLR Profiling. Note that some of the MSDN articles were written long ago on older versions of the profiling API, so some of the details may out of date. But the overall, general structure of how a profiler is built remains unchanged.


 
 
David Broman - MSFT





PostPosted: Building Development and Diagnostic Tools for .Net, ICorProfilerCallback learning : Please help get me started Top

One other thing. The samples in the MSDN articles I listed are great to start with, but many people also like to start their profiler with code based off of the sample memory profiler that Microsoft created (simply named "CLR Profiler"), which you can find here:

http://www.microsoft.com/downloads/details.aspx FamilyID=a362781c-3870-43be-8926-862b40aa0cd0&DisplayLang=en

Note that CLRProfiler is fairly complex, and includes a managed-code portion for the UI (which isn't strictly considered a "profiler"), as well as the native COM DLL (which IS the profiler). So it might be a little too complex to use as your first example. But you may want to refer to it once you've learned some of the basics.