<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Visual Studio Profiler Team Blog : colin</title><link>http://blogs.msdn.com/profiler/archive/tags/colin/default.aspx</link><description>Tags: colin</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>VS2010: Attaching the Profiler to a Managed Application</title><link>http://blogs.msdn.com/profiler/archive/2009/12/07/vs2010-attaching-the-profiler-to-a-managed-application.aspx</link><pubDate>Mon, 07 Dec 2009 19:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9933655</guid><dc:creator>profiler</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/profiler/comments/9933655.aspx</comments><wfw:commentRss>http://blogs.msdn.com/profiler/commentrss.aspx?PostID=9933655</wfw:commentRss><description>&lt;P&gt;Before Visual Studio 2010, in order to attach the profiler to a managed application, certain environment variables had to be set using vsperfclrenv.cmd. An example profiling session might look like this:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;vsperfclrenv /sampleon &lt;/LI&gt;
&lt;LI&gt;[Start managed application from the same command window] &lt;/LI&gt;
&lt;LI&gt;vsperfcmd /start:sample /output:myapp.vsp /attach:[pid] &lt;/LI&gt;
&lt;LI&gt;[Close application] &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If the environment variables were not correctly set, when attempting to attach you would see this message: &lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/profiler/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/old_attach_warning_2.png" mce_href="http://blogs.msdn.com/blogfiles/colinth/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/old_attach_warning_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=old_attach_warning border=0 alt=old_attach_warning src="http://blogs.msdn.com/blogfiles/profiler/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/old_attach_warning_thumb.png" width=560 height=312 mce_src="http://blogs.msdn.com/blogfiles/colinth/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/old_attach_warning_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P align=center&gt;&lt;EM&gt;The profiling environment for ConsoleApplication2 is not set up correctly. Use vsperfclrenv.cmd to setup environment variables. Continue anyway?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;The generated report would typically look something like the report below. The warning at the bottom of the page indicates the problem and the report itself would typically not be useful since no managed modules or functions would be resolved correctly.&lt;/P&gt;
&lt;P align=center&gt;&lt;A href="http://blogs.msdn.com/blogfiles/profiler/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/old_attach_badreport_2.png" mce_href="http://blogs.msdn.com/blogfiles/colinth/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/old_attach_badreport_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=old_attach_badreport border=0 alt=old_attach_badreport src="http://blogs.msdn.com/blogfiles/profiler/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/old_attach_badreport_thumb.png" width=642 height=437 mce_src="http://blogs.msdn.com/blogfiles/colinth/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/old_attach_badreport_thumb.png"&gt;&lt;/A&gt;&lt;EM&gt;&amp;nbsp; Report with 'CLRStubOrUnknownAddress and Unknown Frame(s) and the warning ‘It appears that the file was collected without properly setting the environment variables with VSPerfCLREnv.cmd. Symbols for managed binaries may not resolve’.&lt;/EM&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Fortunately the Common Language Runtime (CLR) team provided us with a new capability to attach to an already running managed application without setting any environment variables. For more detailed information take a look at &lt;A href="http://blogs.msdn.com/davbr/archive/2009/11/04/clr-v4-profiler-attach-basics-with-sample-code.aspx" mce_href="http://blogs.msdn.com/davbr/archive/2009/11/04/clr-v4-profiler-attach-basics-with-sample-code.aspx"&gt;David Broman’s post&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Caveats:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;We only support attach without environment variables for basic sampling. It will not work for Allocation or Object Lifetime data collection and Instrumentation attach is not possible. Concurrency (resource contention) attach is supported. &lt;/LI&gt;
&lt;LI&gt;The new attach mechanism only works for CLR V4-based runtimes. &lt;/LI&gt;
&lt;LI&gt;The new attach mechanism will work if your application has multiple runtimes (i.e. V2 and V4&amp;nbsp; SxS), but as noted above, you can only attach to the V4 runtime. I’ll write another post about the profiler and Side by Side (SxS). &lt;/LI&gt;
&lt;LI&gt;The old environment-variable-based attach still works, so you can still use that if you prefer. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The new procedure for attaching the profiler to a managed application in Visual Studio 2010 goes like this:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Launch your app (if it isn’t already running) &lt;/LI&gt;
&lt;LI&gt;Attach to it, either from the command-line or from the UI. &lt;/LI&gt;
&lt;LI&gt;When you’re finished, detach or close the app to generate a report. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/profiler/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/new_attach_report_2.png" mce_href="http://blogs.msdn.com/blogfiles/colinth/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/new_attach_report_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=new_attach_report border=0 alt=new_attach_report src="http://blogs.msdn.com/blogfiles/profiler/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/new_attach_report_thumb.png" width=616 height=482 mce_src="http://blogs.msdn.com/blogfiles/colinth/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/new_attach_report_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you want to diagnose any issues with attach, the CLR V4 runtime provides diagnostic information via the Event Log (view with Event Viewer) and the profiler also displays information there:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/profiler/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/new_attach_eventlog_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=new_attach_eventlog border=0 alt=new_attach_eventlog src="http://blogs.msdn.com/blogfiles/profiler/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/new_attach_eventlog_thumb.png" width=644 height=229 mce_src="http://blogs.msdn.com/blogfiles/colinth/WindowsLiveWriter/VS2010AttachingtheProfilertoManagedAppli_DEA7/new_attach_eventlog_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P align=center&gt;&lt;EM&gt;Event Log: ‘Loading profiler. Running CLR: v4.0.21202. Using ‘Profile First’ strategy’&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;There are two .NET Runtime messages regarding the attach, the first indicating that an attach was requested and the second that the attach succeeded. The VSPERF message describes which CLR is being profiled.&lt;/P&gt;
&lt;P&gt;[&lt;A href="http://blogs.msdn.com/colinth" mce_href="http://blogs.msdn.com/colinth"&gt;Colin Thomsen&lt;/A&gt;]&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9933655" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/profiler/archive/tags/profiler/default.aspx">profiler</category><category domain="http://blogs.msdn.com/profiler/archive/tags/colin/default.aspx">colin</category><category domain="http://blogs.msdn.com/profiler/archive/tags/vs2010/default.aspx">vs2010</category></item><item><title>Welcoming Colin to the profiler team</title><link>http://blogs.msdn.com/profiler/archive/2007/05/11/welcoming-colin-to-the-profiler-team.aspx</link><pubDate>Sat, 12 May 2007 01:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2554486</guid><dc:creator>profiler</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/profiler/comments/2554486.aspx</comments><wfw:commentRss>http://blogs.msdn.com/profiler/commentrss.aspx?PostID=2554486</wfw:commentRss><description>
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt;"&gt;We recently added a new team member here in profiler land and he’s up and kicking with a blog already. Check out Colin’s blog &lt;a href="http://blogs.msdn.com/colinth/" class="" mce_href="http://blogs.msdn.com/colinth/"&gt;here&lt;/a&gt; for his first entry on &lt;a href="http://blogs.msdn.com/colinth/archive/2007/05/07/basic-profiler-scenarios.aspx" class="" mce_href="http://blogs.msdn.com/colinth/archive/2007/05/07/basic-profiler-scenarios.aspx"&gt;basic profiler scenarios&lt;/a&gt;.&lt;/p&gt;

&lt;p class="MsoNormal" style="margin: 0in 0in 10pt;"&gt;~Ian &lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2554486" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/profiler/archive/tags/profiler/default.aspx">profiler</category><category domain="http://blogs.msdn.com/profiler/archive/tags/colin/default.aspx">colin</category></item></channel></rss>