VS2013: "VSP2340: environment variables were set incorrectly" even when working with IDE

I am profiling a C # program from Visual Studio 2013. I go to Analyze -> Performance and Diagnostics to start the wizard. This gives me a choice of profiling method. If I choose the default processor selection, then profiling, and I can see the results. However, if I choose the third option, .NET memory allocation, then after completing my application, I see empty results and this error in the Visual Studio output window:

VSP2340: Environment variables were not properly set during profiling run and managed symbols may not resolve. Please use vsperfclrenv before profiling 

All the documentation that I saw on the Internet suggests that vsperfclrenv is for use with the standalone profiler and is not needed when starting the profiler directly from Visual Studio. However, to be safe, I tried to set the necessary environment variables from the command line window, and then start the IDE directly from this window so that it would take the environment:

 C: cd "\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\x64" vsperfclrenv /samplegclife /tracegclife /globalsamplegclife /globaltracegclife "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" 

Then I went to the performance wizard inside Visual Studio, as before. But the result is the same; I still see the VSP2340 trying to analyze the results. What am I doing wrong?

I note that the wizard has four types of profiling: processor selection, toolkit, memory allocation, and resource competition. This does not quite correspond to the parameters proposed by vsperfclrenv , which speaks only about sample inspection and trace profiling (with various service options for each of them: my program is an application, not a service, but I turned on all the parameters, I am sure).

Could there be an additional environment variable needed to profile memory allocation? Or is Visual Studio's message about vsperfclrenv misleading?

+6
source share
2 answers

This may be due to administrator privileges. In my case, I know two workarounds:

  • Start Visual Studio as a user with real administrator rights.
  • Use the command [Start → Microsoft Visual Studio 2012 → Visual Studio Tools →] for VS2012 → Run as administrator. At the command line vsperfclrenv /samplegclife . The window name changes from Administrator: Developer Command Prompt for VS2012 to Administrator: VSPerf Sampling Attaching and Allocation Profiling with objects lifetime 'ON' . Then "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" .

The second approach looks exactly like the original poster did, except that instead of the usual cmd.exe window, I used Run as administrator using the developer's command line. For me, when I do not start as an administrator, I get error VSP2340.

I had very similar symptoms with a slightly different environment: Windows 7, as a regular user (not in the local Administrators group), running Visual Studio 2012 from the Start menu using Avdeo Defendpoint to provide elevated privileges, Visual Studio performed CPU profiling got normal results, but the results of the .NET memory allocation sample were empty. Exit window:

 Profiling started. Profiling process ID #### (xxxx). Process ID #### has exited. Data written to C:\path\to\solution\xxxxyymmdd.vsp. Profiling finished. VSP2340: Environment variables were not properly set during profiling run and managed symbols may not resolve. Please use vsperfclrenv before profiling. Profiling complete. 

To run CPU profiles instead of VSP2340, I get a long list of Loaded symbols for [full/path/to/dll]

+1
source

Have you tried to run the Visual Studio command prompt (as administrator) and run the vsperfclrenv / globalsampleon command? After that, you may need to reboot.

0
source

Source: https://habr.com/ru/post/976209/


All Articles