Visual Studio性能分析-找不到类库符号
本文关键字:找不到 类库 符号 Studio 性能 Visual | 更新日期: 2023-09-27 18:25:52
我正在尝试使用Visual Studio 2012.NET 4来检测ASP.NET web应用程序。该解决方案包含一个web应用程序和一个类库。问题是我看不到进入类库的步骤,我收到一条消息:
Matching symbols could not be found. Choose the 'Symbol Settings...' link to add the symbol file location and then reload the report.
评测时的输出看起来不错:
Preparing web server for profiling.
Profiling started.
Instrumenting C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest''bin'PerformanceTest.dll in place
Info VSP3049: Small functions will be excluded from instrumentation.
Microsoft (R) VSInstr Post-Link Instrumentation 11.0.50727 x86
Copyright (C) Microsoft Corp. All rights reserved.
File to Process:
C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'bin'PerformanceTest.dll --> C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'bin'PerformanceTest.dll
Original file backed up to C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'bin'PerformanceTest.dll.orig
Successfully instrumented file C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'bin'PerformanceTest.dll.
Warning VSP2013: Instrumenting this image requires it to run as a 32-bit process. The CLR header flags have been updated to reflect this.
Instrumenting C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'SomeLibrary'obj'Debug'SomeLibrary.dll in place
Info VSP3049: Small functions will be excluded from instrumentation.
Microsoft (R) VSInstr Post-Link Instrumentation 11.0.50727 x86
Copyright (C) Microsoft Corp. All rights reserved.
File to Process:
C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'SomeLibrary'obj'Debug'SomeLibrary.dll --> C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'SomeLibrary'obj'Debug'SomeLibrary.dll
Original file backed up to C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'SomeLibrary'obj'Debug'SomeLibrary.dll.orig
Successfully instrumented file C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'SomeLibrary'obj'Debug'SomeLibrary.dll.
Warning VSP2013: Instrumenting this image requires it to run as a 32-bit process. The CLR header flags have been updated to reflect this.
Launching web server with profiling.
Launching profilable project.
Warning VSP2355: Some Windows counters will not be collected. Without this data, some performance rules may not fire.
Profiling process ID 68 (iisexpress).
Process ID 68 has exited.
Data written to C:'Users'kipusoep'Documents'InfoCaster'svn'instances'PerformanceTest'PerformanceTest_130801(1).vsp.
Profiling finished.
Loaded symbols for C:'Windows'Microsoft.NET'Framework'v4.0.30319'Temporary ASP.NET Files'root'0329cb19'89f716fc'App_Web_0slsprtu.dll.
Loaded symbols for C:'Windows'Microsoft.NET'Framework'v4.0.30319'Temporary ASP.NET Files'root'0329cb19'89f716fc'assembly'dl3'62c5c0d2'9777513f_ae8ece01'PerformanceTest.dll.
Profiling complete.
我注意到输出在末尾没有说明任何关于名为"SomeLibrary"的类库的内容,它说"Loaded symbol for"。
有人知道我为什么不能给类库装仪器吗?
以下是VS解决方案:http://www.fileswap.com/dl/C9HPd8uEC/
据我从您的解决方案中所知,正在插入指令的.dll位于类库的"obj"文件夹中。
现在,这可能只是我在说什么时候应该闭嘴(因为我对Visual Studio探查器没有什么了解,我不知道为什么/如果有人想检测"obj"二进制文件而不是"bin"),因此,我想我最好描述一下我的思路:
VS正在"ASP.NET临时文件"位置查找符号文件(特别是.instr.pdb文件),因为它是从那里加载类库dll的。不过,它找不到它,因为该文件是在类库项目的obj''Debug中创建的,并且没有复制到web应用程序的"bin"文件夹中,因此它也从未被卷影复制到"ASP.NET临时文件"中。
从性能浏览器中删除目标并选择"添加项目目标",检查这两个项目,可以准确地告诉我你(和我)以前的情况:
- Web应用程序项目中的PerformanceTest.dll。。。''bin ''调试
- 类库项目的SomeLibrary.dll。。。''obj''调试
很明显,这就是VS想要的样子,不管它是否有效。它在obj''Debug中插入类库,然后在启动探查器时忘记所有新生成的符号。
但是如果我再次删除"SomeLibrary.dll"目标,请选择"添加目标二进制文件…"并手动选择web应用程序的。。。''bin ''调试。。。然后开始分析:报告看起来大致相同,但我可以浏览到"SomeLibrary",并在输出中得到:
Preparing web server for profiling.
Profiling started.
Instrumenting E:'...'PerformanceTest''bin'PerformanceTest.dll in place
Info VSP3049: Small functions will be excluded from instrumentation.
Microsoft (R) VSInstr Post-Link Instrumentation 11.0.50727 x86
Copyright (C) Microsoft Corp. All rights reserved.
File to Process:
E:'...'PerformanceTest'bin'PerformanceTest.dll -->
E:'...'PerformanceTest'bin'PerformanceTest.dll
Original file backed up to E:'...'PerformanceTest'bin'PerformanceTest.dll.orig
Successfully instrumented file E:'...'PerformanceTest'bin'PerformanceTest.dll.
Warning VSP2013: Instrumenting this image requires it to run as a
32-bit process. The CLR header flags have been updated to reflect this.
Instrumenting E:'...'PerformanceTest'bin'SomeLibrary.dll in place
Info VSP3049: Small functions will be excluded from instrumentation.
Microsoft (R) VSInstr Post-Link Instrumentation 11.0.50727 x86
Copyright (C) Microsoft Corp. All rights reserved.
File to Process:
E:'...'PerformanceTest'bin'SomeLibrary.dll -->
E:'...'PerformanceTest'bin'SomeLibrary.dll
Original file backed up to E:'...'PerformanceTest'bin'SomeLibrary.dll.orig
Successfully instrumented file E:'...'PerformanceTest'bin'SomeLibrary.dll.
Warning VSP2013: Instrumenting this image requires it to run as a
32-bit process. The CLR header flags have been updated to reflect this.
Launching web server with profiling.
Launching profilable project.
Profiling process ID 14652 (iisexpress).
Process ID 14652 has exited.
Data written to E:'...'PerformanceTest'PerformanceTest_130810(1).vsp.
Profiling finished.
Loaded symbols for
C:'...'App_Web_yzwcgfbx.dll.
Loaded symbols for
C:'...'assembly'dl3'928eb82e'75dbb6f1_5695ce01'PerformanceTest.dll.
Loaded symbols for
C:'...'assembly'dl3'6c0d460d'5208c7f1_5695ce01'SomeLibrary.dll.
Profiling complete.
这是解决问题的正确方法吗?再说一遍,我不知道。如果没有,可能有一种方法可以让探查器在类库的obj文件夹中查找符号,当它找不到预期的位置时,也可以将.instr.pdb文件复制到bin文件夹中进行预分析,以便将其包含在ASP.NET临时文件的卷影副本中。
我在VS2014中遇到了这个问题,该exe是为"任何CPU"构建的,设置了"首选32位",而引用的库没有"首选32位数"(即32位exe,64位库)。
将exe更改为不"首选32位"解决了符号的问题,我认为这是因为库被修改为与exe的位匹配(在插入过程中),而符号不再匹配。
这个解决方案对我有效:
http://www.brothersincode.com/post/Matching-symbols-could-not-be-found-Performance-Profiler.aspx
你也可以用另一种方式尝试,这意味着删除你的dll,并尝试将其从垃圾箱中放入,因为这也可能是另一种方法。
我已经成功地配置了我的类库,但只能从控制台应用程序中配置。在ASP.NET应用程序性能评测会话期间,我无法评测类库。
一些各种各样的链接-唉,这并没有解决我的问题,但可能会给你一些线索:
- 运行
Developer Command Prompt for VS2012
- 然后,您可以将其用于
VSPerfReport <yourreport.vsp> /debugsympath
,以确定SomeLibrary.dll应该从何处加载 - 疑难解答提示http://msdn.microsoft.com/en-us/library/bb385766.aspx
目前接受的答案帮助我达到了目标,但我会谦虚地给那些试图完成与我完全相同的事情的人一些更直接的指示,以防我为某人节省几个小时的谷歌搜索时间。我尝试评测一个使用外部程序集的WCF服务失败,这些程序集在运行时由反射加载,并由我的自定义客户端触发此服务。我有两个问题:我的WCF服务在分析会话期间根本没有启动(但在调试时它总是会启动),然后当它因为某种原因启动时——Visual Studio无法加载外部程序集的符号。因此,为了使这两件事都起作用,我需要创建一个检测性能会话,将目标设置为我的主WCF服务以及自定义外部程序集,并设置启动模式-Internet Explorer(否则服务将无法启动)。没有前任或从解决方案指向客户。然后我没有立即启动探查器,而是在"性能资源管理器"窗口中修改了它的属性,并将我的自定义客户端的二进制文件添加到"启动"选项卡中,以便在第2次启动(就在服务inself之后)。这也有助于在客户端中拥有正确的"服务引用"(我并没有真正使用它,我使用共享程序集并使用ChannelFactory生成通道),并首先在调试模式下启动客户端(但实际上从未访问过服务)。也许这不是正确的方法,但它确实奏效了,经过2天的谷歌搜索,我终于可以介绍我的服务了——关于这个主题的文档不多,这个stackoverflow问题的公认答案是我找到的最好的资源。
我正在使用Visual Studio 2019,在对ASP.NET网站进行仪器分析时遇到了同样的问题。
深受上述JimmiTh解决方案的启发,我将缺失项目的[ProjectPath]/obj/Debug路径添加到VS选项->调试->符号中。再次分析后,我可以很容易地访问源代码,并获得更准确的分析诊断。