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

查看:24
本文介绍了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.0Team ToolsPerformance Toolsx64"
vsperfclrenv /samplegclife /tracegclife /globalsamplegclife /globaltracegclife
"C:Program Files (x86)Microsoft Visual Studio 12.0Common7IDEdevenv.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 提供的选项不太匹配,后者只讨论采样和跟踪分析(每个应用程序与服务变体;我的程序是应用程序而不是服务,但我启用了所有选项只是为了确定).

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 Life 'ON'.然后C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDEdevenv.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.0Common7IDEdevenv.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,作为普通用户(不在本地管理员组中),从开始"菜单启动 Visual Studio 2012,使用 Avecto Defendpoint 向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	osolutionxxxxyymmdd.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,我得到一长串 已加载的 [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天全站免登陆