How to profile ASP.NET and Silverlight at the same time


In Visual Studio 2010 SP1 we enabled the ability to profile Silverlight applications from the Visual Studio UI.  Unfortunately there is a limitation where we cannot automatically attach to multiple processes on launch from inside Visual Studio, so you are still unable to profile ASP.NET and Silverlight at the same time without manually attaching to Internet Explorer after launch.  Fortunately, this is relatively simple. 

To profile both Silverlight and ASP.NET at the same time:

  1. Launch your CPU sampling session against your ASP.NET application from Visual Studio
  2. In the Performance Explorer window click “Attach/Detach”

    image

  3. Select the Internet Explorer process that is running your Silverlight application—if you only have one instance of Internet Explorer open with a single tab, the process will be the “iexplore” process without a Window Title. 

    image

    • If you have multiple instances of Internet Explorer open, or multiple tabs inside internet explorer, you can either:
      • Try looking at the CPU consumption of your iexplore.exe processes in Task Manager to see which one is most active
      • Use Process Explorer
        • Find –>  “Find Handle or DLL…” (ctrl + F)
        • Search for “coreclr.dll”
        • The “iexplore.exe” process with this dll loaded is the PID you want to attach to

          image

  4. You are now profiling ASP.NET and Silverlight at the same time


Comments (7)

  1. Gary says:

    Thanks,But how can I instument a SL app?

  2. andrehal says:

    Currently Silverlight only supports CPU sampling, so Silvelight applications cannot be instrumented

  3. tomas.k says:

    Hi,

    I have problem that when I attach to IE (v9) the whole browser crash! After that when I start to analyze the vsp file, there are only data from web (sever) part, the Visual Studio crash too! So what is it?

    Thank you

  4. andrehal says:

    @tomas.k have you installed SP1, there were changes in IE9 that require updates in the Visual Studio 2010 SP1 to profile against IE9

  5. Mobbe says:

    Following the instructions for attaching. I have one IE8 running with one tab so I pick the ieprocess without the name. When I do I get a message saying " It is not possible to profile 32-bit and 64-bit at the same time". I am running on Windows 7 Enterprise 64 bit OS, with IE8, VS.NET 2010 SP1 and the latest Silverlight 4 bits. Any ideas how to get around this would be great. Thanks

  6. andrehal says:

    @Mobbe, are you running your ASP.NET site inside IIS?  If so, it sounds like IIS is running as a 64 bit process, since IE is running as a 32bit process, you'll need to change your IIS threadpool to 32bit in order to profile them at the same time

  7. Mobbe says:

    Thanks, I changed the setting on my AppDomain in IIS to 32 and now I am able to profile.