Application Insights 因加载 System.Reflection.TargetInvocationException 而失败 - WP 8.1

Application Insights failing with System.Reflection.TargetInvocationException on load - WP 8.1

我开始探索 Application Insights 并尝试将其添加到我的 Windows Phone 8.1 应用程序中。尝试执行项目时,在 App.xaml.vb 中的 Public Sub New() 内加载时抛出异常。发生错误的行是

TelemetryClient = new TelemetryClient()

抛出的异常是

A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll

An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: Exception has been thrown by the target of an invocation.

内部异常详细信息:

{System.InvalidOperationException: Type 'Microsoft.ApplicationInsights.Extensibility.ComponentContextInitializer, Microsoft.ApplicationInsights, Version=0.16.1.418, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not implement the required interface

Microsoft.ApplicationInsights.Extensibility.IContextInitializer. at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.CreateInstance(Type interfaceType, String typeName) at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstance(XElement definition, Type expectedType, Object instance) at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstances[T](XElement definition, ICollection`1 instances)}

我遵循了 in the Azure documentation 概述的步骤。我可能做错了什么?

您是在 Windows 运行时还是在 Silverlight 上使用 Windows Phone 应用程序?

如果您从 ApplicationInsights.config 中删除以下行,您的应用是否成功启动?

    <Add Type="Microsoft.ApplicationInsights.Extensibility.ComponentContextInitializer, Microsoft.ApplicationInsights"/>

原来这是一个损坏的解决方案。我添加了 nuget,然后添加了 Application Insights。在此期间,我将 nugget 包升级到 0.16 预发布版本。实际上,它创建了多个引用。所以我最终手动清除了 package.config 和 .vbproj 中 Microsoft.ApplicationInsights 的所有条目。我还删除了所有引用并再次引用了整个内容。现在它就像一个魅力!