首页 文章

应用程序见解向导失败

提问于
浏览
4

我尝试使用Visual Studio向导将Application Insights添加到我的应用程序中 . 当我在我的办公室电脑上做它时它工作得很好 . 但是,当我尝试在家中执行此操作时,它失败并显示以下错误消息:

---------------------------
Microsoft Visual Studio
---------------------------
Could not add Application Insights to project.  

Failed to install package: 
Microsoft.ApplicationInsights.Web 

with error: 
Unable to resolve dependencies.  'Microsoft.ApplicationInsights 2.5.0' is not compatible with 

'Microsoft.ApplicationInsights.DependencyCollector 2.4.1 constraint: Microsoft.ApplicationInsights (= 2.4.0)', 
'Microsoft.ApplicationInsights.PerfCounterCollector 2.4.1 constraint: Microsoft.ApplicationInsights (= 2.4.0)', 
'Microsoft.ApplicationInsights.Web 2.4.1 constraint: Microsoft.ApplicationInsights (= 2.4.0)', 
'Microsoft.ApplicationInsights.WindowsServer 2.4.1 constraint: Microsoft.ApplicationInsights (= 2.4.0)', 
'Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.4.0 constraint: Microsoft.ApplicationInsights (= 2.4.0)'.

似乎我在某些部件中安装了2.5.0,在其他部件中安装了2.4 . 但是我不知道会导致什么......我只是跑了向导 . 除了Visual Studio之外,我没有安装任何东西(与App Insights相关) .

我之后尝试安装Application Insights Status Monitor,但它不会影响错误 .

如何处理这个错误的任何想法将不胜感激...

细节:

  • 我正在运行一个Web API项目

  • 我在完整的.net框架上运行(版本4.5.2)

2 回答

  • 2

    根据How NuGet resolves package dependencies .

    无论何时安装或重新安装软件包(包括作为还原过程的一部分安装),NuGet还会安装第一个软件包所依赖的任何其他软件包 . 那些直接的依赖关系也可能依赖于它们自己,这可以继续任意深度 . 这产生了所谓的依赖图,它描述了所有级别的包之间的关系 .


    在程序包还原操作期间,您可能会看到错误“一个或多个程序包不兼容...”或程序包与项目的目标框架“不兼容” . 当项目中引用的一个或多个包未指示它们支持项目的目标框架时,会发生此错误;也就是说,程序包在其lib文件夹中不包含适合与项目兼容的目标框架的DLL .

    所以,我认为这是因为包的依赖性问题 .

    根据nuget.orgMicrosoft.ApplicationInsights.DependencyCollector 2.4.1Microsoft.ApplicationInsights.PerfCounterCollector 2.4.1Microsoft.ApplicationInsights.Web 2.4.1Microsoft.ApplicationInsights.WindowsServer 2.4.1Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.4.0完全要求ie = => Microsoft.ApplicationInsights 2.4.0但你有Microsoft.ApplicationInsights 2.5.0

    所以你需要将Microsoft.ApplicationInsights 2.5.0降级为Microsoft.ApplicationInsights 2.4.0 .

    要降级Microsoft.ApplicationInsights 2.5.0,您可以卸载软件包并安装所需的软件包版本 . 您可以按照以下命令操作 .

    Uninstall-Package Microsoft.ApplicationInsights -Force
    Install-Package Microsoft.ApplicationInsights -Version 2.4.0
    

    请注意 - Force 参数 . 强制卸载程序包,即使其他程序包依赖它也是如此 .

    或者您可以尝试重新安装 Microsoft.ApplicationInsights

    Update-Package -Reinstall Microsoft.ApplicationInsights
    

    或者你可以升级 Microsoft.ApplicationInsights 的所有依赖项

    Update-Package Microsoft.ApplicationInsights.DependencyCollector -Version 2.5.0
    Update-Package Microsoft.ApplicationInsights.PerfCounterCollector -Version 2.5.0
    Update-Package Microsoft.ApplicationInsights.Web -Version 2.5.0
    Update-Package Microsoft.ApplicationInsights.WindowsServer -Version 2.5.0
    Update-Package Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel -Version 2.5.0
    
  • -1

    你可以尝试的事情:

    • 确保启用了工具栏:查看 - >工具栏 - >应用程序洞察 .

    • 关闭VS,并以管理员身份启动一次 . 在以管理员身份运行之前,您可能有旧的自动更新的扩展等未经清理的扩展 . 然后关闭该管理员VS并返回正常的非管理员VS.

    • 卸载并重新安装Microsoft.ApplicationInsights.Web包;然后,右键单击Web项目并“配置应用程序洞察” .

相关问题