Search code examples
c#.netnugetazure-application-insightstelemetry

Microsoft.ApplicationInsights.Contracts does not exist in Microsoft.ApplicationInsights


I wanted to have a go at Microsoft.ApplicationInsights telemetry. Documentation claims that TelemetryContext is supposed to be in Microsoft.ApplicationInsights.Contracts namespace, however when I grab Application Insights for Web from nuget (it gets me Microsoft.ApplicationInsights as dependency), it does not seem to have Contracts in it.

Microsoft.ApplicationInsights.Contracts nuget search gives no results.

I must be missing something obvious here.


Solution

  • The documentation on MSDN appears to be out of date.

    In 1.1 of the Application Insights SDK (the latest, which I'm assuming you are using), has TelemetryContext in this namespace: Microsoft.ApplicationInsights.DataContracts (note DataContracts not just Contracts). I used Resharper to let it find the TelemetryContext class and it found it in this namespace in the core package (Microsoft.ApplicationInsights).

    The SDK release notes do not mention anything specifically about this namespace moving however, https://azure.microsoft.com/en-us/documentation/articles/app-insights-release-notes-dotnet/.