Search code examples
visual-studioprofilervisual-studio-2015

Enabling Profiler without reboot


Every time I want to profile an application with Visual Studio I have to run vsperfclrenv /globalsampleon as recommended here and here (I have it normally switched off because I love the "edit and continue"-feature). The command prompt then states:

Enabling VSPerf Global Profiling. Allows to 'attaching' to managed services.
You need to restart the service to detect the new settings. This may require a reboot of your machine.

So far I haven't found a way to restart the service (as mentioned in the prompt) without rebooting my computer. Is there another way?


EDIT to add some information from the comments:

  • I am profiling an application that I start from Visual Studio
  • I use another instance of Visual Studio to profile the application via "attach profiler"

Solution

  • You do not need to run "vsperfclrenv /globalsampleon" and reboot if an application you profile can be launched from command line. In this case you can invoke "vsperfclrenv /sampleon" from command prompt and then launch you application from the same prompt. This will set proper environment for a process being profiled.

    However, if your application cannot be launched from command line (e.g. you profile a managed service) then you need to invoke "vsperfclrenv /globalsampleon" and reboot to apply proper environment changes system-wide. A reboot is recommended because without it in some cases the environment changes are not successfully broadcasted system-wide.

    You can find more information here and here.

    UPD: Specifically, for your scenario please invoke "vsperfclrenv /sampleon" from VS developer prompt, start VS via invoking "devenv" from that prompt and use that VS instance to start an application. So, your application should have necessary environment set. Another VS instance which you use to attach can be run as usual.