我有一个面向 .NET Framework 4.6.2(VB.NET,而不是 C#)的 ASP.NET Web 应用程序。我在本地使用 IIS 运行它。
当我使用 NuGet 安装 Microsoft.ApplicationInsights 2.21.0 并在本地重新加载站点时,我收到服务器错误:
Server Error in '/' Application. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
三点考虑:
我没有更改任何代码 - 我只是安装了该软件包。
本项目中为
Microsoft.ApplicationInsights
2.21.0 安装的依赖关系树 NuGet 包括:
System.Buffers.4.5.1
System.Numerics.Vectors.4.5.0
System.Runtime.CompilerServices.Unsafe.5.0.0
System.Memory.4.5.4
System.Diagnostics.DiagnosticSource 5.0.0
Microsoft.ApplicationInsights.2.21.0
我的项目中不存在这些,所以我确信我只安装了新的软件包,这些软件包不应与任何预先存在的依赖项发生冲突或交叉。
我尝试擦除 bin 和 obj 文件夹,然后重新启动 IIS。没有帮助。
我配置 NuGet 来恢复包并删除了解决方案中的所有包并重新构建它。这也没有帮助。
该项目有已弃用的软件包。但是,它们与 AppInsights 无关,我希望尽可能避免重写。
一般来说,似乎在引用 GAC 中的一个或多个程序集的一个或多个依赖关系树中存在依赖关系冲突,但我没有明确的方法来识别树或修复它/它们.
如果任何现有包都没有引用任何新包,我如何诊断哪个包/程序集导致了此错误?
“/”应用程序中的服务器错误。无法加载一种或多种请求的类型。检索 LoaderExceptions 属性以获取更多信息。
正如您提到的,该错误可能是由于错误之间的兼容性或冲突造成的,并且应用程序代码也一定存在一些问题。
尝试手动配置 Application Insights,请参阅 MSDOC:
project=>configure Application Insights
:Application Insights sdk
=>Next=>Finish=>Close
。ApplicationInsights.config
中添加您的 Application Insights 连接字符串。 <ConnectionString>your_application_insights_connection_string</ConnectionString>
</ApplicationInsights>
我尝试在我的 .NET Web 应用程序版本 4.8 (vb.net) 中安装 Application Insights 软件包版本
2.21.0
。
我可以毫无问题地运行该应用程序:
我的项目参考: