今天,我只是在 Instrumentation 模式下使用 Visual Studio 的分析器来分析我的 WCF 应用程序。后来我需要发布到我的网络服务器,突然我收到一条错误消息,指出找不到 Microsoft.VisualStudio.Enterprise.AspNetHelper 文件路径。
当我查看 web.config 时,我发现分析会话添加了以下几行。
<system.web>
<compilation targetFramework="4.0" debug="true" assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter,
Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<runtime>
<generatePublisherEvidence enabled="false"/>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<codeBase version="12.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2012.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.AspNetHelper.DLL"/>
</dependentAssembly></assemblyBinding></runtime>
<appSettings>
<!--<add key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation" value="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Performance Tools\vsinstr.exe"/>-->
</appSettings></configuration>
很明显,它会在服务器上查找某些 DLL,但由于未安装 VS,该路径在服务器上无效,因此会引发异常。为什么会发生这种情况以及如何避免将这些行添加到 web.config 中?每次进行分析会话时删除这些行将非常麻烦。
UPDATE:在VS2015上也出现这个问题。如果启动 VS 分析工具,它会在 web.config 中添加一行
> <add
> key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation"
> value="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team
> Tools\Performance Tools\vsinstr.exe"/> <dependentAssembly>
> <assemblyIdentity name="Microsoft.VisualStudio.Enterprise.AspNetHelper"
> culture="neutral"/>
> <codeBase version="14.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2014.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.AspNetHelper.DLL"/></dependentAssembly>
如果您发布到服务器,您将收到以下错误
Configuration error
处理配置文件时发生错误。
此请求需要该信息。检查具体错误详情
下面并适当修改您的配置文件。
解析器错误消息:文件或程序集
'Microsoft.VisualStudio.Enterprise.AspNetHelper,版本= 14.0.0.0,
Culture = 中立,PublicKeyToken = “或其其中之一
未找到依赖项。该系统找不到指定的文件。
来源错误:
服务器上发生应用程序错误。由于目前的习俗
此应用程序的错误设置 应用程序的详细信息
可以显示远程错误(出于安全原因)。然而,他们
可以通过本地服务器上运行的浏览器查看。
源文件:C:\www\web.config
线路:52
负载跟踪组件:可以通过以下信息确定,
为什么程序集 Microsoft.VisualStudio.Enterprise.AspNetHelper,
版本 = 14.0.0.0,文化 = 中性,PublicKeyToken =
b03f5f7f11d50a3a 无法加载。
警告:程序集绑定日志记录已关闭。您可以启用日志记录程序集
绑定失败,删除注册表值[HKLM\Software\Microsoft\
融合! EnableLog] (DWORD) 为 1 组。注意:程序集绑定日志记录
错误会导致一定的性能损失。你可以把这个
功能关闭,删除注册表值[HKLM\Software\Microsoft\
融合!启用日志]。