c# - 无法加载文件或程序集 'Microsoft.AspNet.TelemetryCorrelation' 或其依赖项之一。该系统找不到指定的文件

标签 c# asp.net .net asp.net-mvc azure-application-insights

我在 IIS 7(本地 Windows 10 专业版)下有两个 Web 应用程序。根是 MVC .Net 版本 4.7.1。到目前为止,这里的一切似乎都运行良好。但是,在默认站点根目录下设置为单独的应用程序是较旧的 .Net 4.0 版 WebForms 应用程序。

第 4 版应用程序是在 Visual Studio 2015 中构建的,MVC 是使用 Visual Studio 2017 构建的。我让第 4 版 WebForms 应用程序在具有相同设置的不同网站下运行,并且运行良好。它只有在作为不同应用程序在根节点下运行时才会出现问题。我还尝试在两个应用程序上使用不同的应用程序池,以及使用相同的应用程序池,但错误没有发生变化。

我也尝试过卸载 ApplicationInsights 并禁用它,但我遇到了同样的问题。

[FileNotFoundException: Could not load file or assembly 'Microsoft.AspNet.TelemetryCorrelation' or one of its dependencies. The system cannot find the file specified.] System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0 System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +95 System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +64 System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +60 System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +49

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.AspNet.TelemetryCorrelation' or one of its dependencies. The system cannot find the file specified.] System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +558 System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) +30 System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +57 System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +57 System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +182 System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1086 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +120 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +169 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +372 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +329

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.AspNet.TelemetryCorrelation' or one of its dependencies. The system cannot find the file specified.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +118 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +708

最佳答案

在我的例子中,子应用没有使用 ApplicationInsights,我将这些排除项添加到子应用 web.config 文件中。它解决了问题。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="false">
      <remove name="TelemetryCorrelationHttpModule" />
      <remove name="ApplicationInsightsWebTracking" />
    </modules> 
  </system.webServer>
</configuration>

这是我找到答案的讨论主题 https://github.com/aspnet/Microsoft.AspNet.TelemetryCorrelation/issues/21#issuecomment-508535397

我的回答是一个迟到的答案,但它可能对其他人有帮助。

关于c# - 无法加载文件或程序集 'Microsoft.AspNet.TelemetryCorrelation' 或其依赖项之一。该系统找不到指定的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50949255/

相关文章:

c# - ServiceBase.Run(ServiceBase[] ) 方法是否异步运行数组中的所有服务?

.net - 如果您使用需要特定安全权限的属性来装饰您的代码,会收到什么好处?

c# - GridView 中的 Row_DataBound 或 Row_Created 事件

c# - MvcContrib TestHelper 在使用 AssertViewRendered 时给出一个奇怪的错误

c# - 无法找到请求的.Net Framework数据提供程序+ Entity Framework

c# - ASPX 空字符错误

c# - ASP.net 从文件创建一个 Torrent

javascript - 是否可以使用 ReactJS.Net 在服务器端渲染 jQuery?

C# 查找两个字符串之间匹配单词的百分比

c# - 防止在 Visual Studio 2017 中自动启动 WCF 服务主机