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.