visual-studio – 应用程序见解向导失败

我尝试使用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)

最佳答案 根据
How NuGet resolves package dependencies.

Any time a package is installed or reinstalled, which includes being
installed as part of a restore process, NuGet also installs any
additional packages on which that first package depends.

Those immediate dependencies might then also have dependencies on
their own, which can continue to an arbitrary depth. This produces
what’s called a dependency graph that describes the relationships
between packages at all levels.

During a package restore operation, you may see the error “One or more
packages are not compatible…” or that a package “is not compatible”
with the project’s target framework.

This error occurs when one or more of the packages referenced in your
project do not indicate that they support the project’s target
framework; that is, the package does not contain a suitable DLL in its
lib folder for a target framework that is compatible with the project.

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

根据nuget.org,Microsoft.ApplicationInsights.DependencyCollector 2.4.1,Microsoft.ApplicationInsights.PerfCounterCollector 2.4.1,Microsoft.ApplicationInsights.Web 2.4.1,Microsoft.ApplicationInsights.WindowsServer 2.4.1Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.4.0完全要求ie = not> = 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
点赞