4
votes

I tried to use the Visual Studio Wizard to add Application Insights to my application. When I did it on my office computer it worked fine. But when I tried to do it at home, it failed with the following error message:

---------------------------
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)'.

It would seem that I have 2.5.0 installed in some parts, and 2.4 installed in other parts. But I don't know what would cause this... I just ran the wizard. I had not installed anything but Visual Studio (in relation to App Insights).

I did try installing the Application Insights Status Monitor afterward, but it did not affect the error.

Any idea on how to deal with this error would be appreciated...

Details:

  • I am running a Web API project
  • I am running on the full .net framework (version 4.5.2)
1
Which framework are you targeting? And what kind of application are you developing? ASP.NET (Core), Azure Functions, UWP, ...rickvdbosch
@rickvdbosch - ASP.NET Web API running on .NET 4.5.2Vaccano
Thanks. Just tried your setup, for me this generates an ASP.NET Web API project that already has Application Insights installed. When I remove it and run the wizard, things work fine. I think you might have packages that conflict with (dependencies for) Application Insights. Could you show us your packages.config file?rickvdbosch

1 Answers

2
votes

According to 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.

So, I think this is because of dependency issues of packages.

According to 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.1 and Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.4.0 require exactly i.e. = not >= Microsoft.ApplicationInsights 2.4.0 but you have Microsoft.ApplicationInsights 2.5.0

So you need to downgrade the Microsoft.ApplicationInsights 2.5.0 to Microsoft.ApplicationInsights 2.4.0.

To downgrade the Microsoft.ApplicationInsights 2.5.0 you can uninstall the package and install the required version of the package. You can follow the following command.

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

Note the -Force parameter. Forces a package to be uninstalled, even if other packages depend on it.

Or you can try to reinstall Microsoft.ApplicationInsights package

Update-Package -Reinstall Microsoft.ApplicationInsights

Or you can upgrade all the dependencies of 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