Partager via


Multiple profilers of managed code on the same machine. Why it is bad?

It may happen that when you try to attach Visual Studio profiler to a managed application, you get the following error:

Error VSP1336 : Could not attach to process ID:1234 MyProcess.exe. Wrong setting of COR_PROFILER environment variable in target process. Please use VSPerfClrEnv.cmd to set environment variables correctly.

You follow the instructions precisely, use VSPerfClrEnv.cmd properly, and it doesn't help. What is wrong?

The next question I would ask you is: "Did you install other profiler on your machine?" If yes, try to uninstall it, reboot the machine and use VSPerfClrEnv.cmd again.

The issue here is that usage of .NET profiling services is bound to the COR_PROFILER environment variable, and each profiler sets it to its own value. Having more than one profiler in field may cause a conflict, where profilers "fight" with each other for the right to set this environment variable. If process is created having this varialbe set by a different profiler, Visual Studio profiler detects this and generates the above error.

Comments

  • Anonymous
    July 27, 2005
    So how about the above message will be changed to:

    Error VSP1336 : Could not attach to process ID:1234 MyProcess.exe. Wrong setting of COR_PROFILER environment variable in target process. Please use VSPerfClrEnv.cmd to set environment variables correctly or check there's no other profiler currently activated.


    This should help
  • Anonymous
    July 31, 2005
    Cleaning-out my “To Blog” file again…
    Architects

    Handling data in service oriented systemsEdward...
  • Anonymous
    March 06, 2006
    The comment has been removed
  • Anonymous
    May 31, 2010
    this is how we do it in detail blogs.msdn.com/.../performance-testing-wcf-web-services-using-vsts-unit-tests.aspx