VS2013:"VSP2340:未正确设置环境变量".即使从IDE运行 [英] VS2013: "VSP2340: Environment variables were not properly set" even when running from IDE

查看:183
本文介绍了VS2013:"VSP2340:未正确设置环境变量".即使从IDE运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Visual Studio 2013中分析C#程序.我转到分析"->性能和诊断"以启动向导.它为我提供了一种分析方法的选择.如果选择默认的CPU采样,则可以进行性能分析,并且可以看到结果.但是,如果我选择第三个选项.NET内存分配,则在我的应用程序完成后,我会在Visual Studio输出窗口中看到空结果和此错误:

I am profiling a C# program from Visual Studio 2013. I go to Analyze -> Performance and Diagnostics to start the wizard. It gives me a choice of profiling method. If I choose the default, CPU sampling, then profiling works and I can see the results. However if I choose the third option, .NET memory allocation, then after my application has finished 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

我在网上看到的所有文档都建议vsperfclrenv用于独立的探查器,而直接从Visual Studio运行探查器时则不需要.但是,为了安全起见,我尝试从命令提示符窗口中设置必要的环境变量,然后直接从该窗口中运行IDE,以便它拾取环境:

All the documentation I've seen online suggests that vsperfclrenv is for use with the stand-alone profiler and is not needed when you run the profiler directly from Visual Studio. However, just to be on the safe side I tried setting the necessary environment variables from a command prompt window and then running the IDE directly from that window, so it picks up 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"

然后,我像以前一样转到Visual Studio中的性能向导.但是结果是一样的.在尝试分析结果时,我仍然看到VSP2340.我在做什么错了?

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

我注意到该向导有四种配置文件可供选择:CPU采样,检测,内存分配和资源争用.这与vsperfclrenv提供的选项并不完全匹配,后者仅讨论采样和跟踪性能分析(每个都有应用程序vs服务变体;我的程序是应用程序而不是服务,但我启用了所有选项只是为了当然).

I note that the wizard has four kinds of profiling to choose: CPU sampling, instrumentation, memory allocation, and resource contention. That doesn't quite match with the options offered by vsperfclrenv, which talks about only sampling and trace profiling (with application vs service variants of each; my program is an application not a service, but I enabled all the options just to be sure).

是否可能需要一些其他环境变量来进行内存分配分析?还是有关vsperfclrenv的Visual Studio消息引起误解?

Could it be there is some additional environment variable needed for memory allocation profiling? Or is the Visual Studio message about vsperfclrenv misleading?

推荐答案

这可能与管理特权有关.就我而言,我知道两种解决方法:

This may be related to administrative privileges. In my case, I know of two workarounds:

  1. 以具有真正管理员权限的用户身份运行Visual Studio.
  2. 使用[开始-> Microsoft Visual Studio 2012-> Visual Studio工具->] VS2012开发人员命令提示符->以管理员身份运行.在命令提示符下,vsperfclrenv /samplegclife.窗口标题从Administrator: Developer Command Prompt for VS2012更改为Administrator: VSPerf Sampling Attaching and Allocation Profiling with objects lifetime 'ON'.然后"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe".
  1. Run Visual Studio as a user with real administrator privileges.
  2. Use the [Start -> Microsoft Visual Studio 2012 -> Visual Studio Tools -> ] Developer Command Prompt for VS2012 -> Run as administrator. In command prompt, vsperfclrenv /samplegclife. Window title 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".

第二种方法看起来与原始发布者一样,只是我在开发人员命令提示符中使用了以管理员身份运行,而不是普通的cmd.exe窗口.对我来说,当我没有以管理员身份运行时,会收到VSP2340错误.

The second approach looks just what the original poster did, except that instead of an ordinary cmd.exe window, I used Run as administrator with the Developer Command Prompt. For me, when I do not run as administrator, I get the VSP2340 error.

我在略有不同的环境中遇到了非常相似的症状:Windows 7,作为普通用户(不在本地Administrators组中),从开始"菜单启动Visual Studio 2012,并使用Avecto Defendpoint授予高级权限给Windows 7. Visual Studio可执行文件,CPU分析产生了正常结果,但.NET内存分配采样结果为空白.输出窗口显示:

I have been experiencing very similar symptoms with a slightly different environment: Windows 7, as a normal user (not in the local Administrators group), starting Visual Studio 2012 from the Start Menu, with Avecto Defendpoint to grant elevated privileges to the Visual Studio executable, CPU profiling produced normal results but .NET memory allocation sampling results were blank. Output window said:

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.

对于CPU分析运行,而不是VSP2340,我得到了很长的Loaded symbols for [full/path/to/dll]

For CPU profiling runs, instead of VSP2340, I get a long listing of Loaded symbols for [full/path/to/dll]

这篇关于VS2013:"VSP2340:未正确设置环境变量".即使从IDE运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆