在一个项目中,我们在C#中调用Powershell脚本。
using (var runspace = RunspaceFactory.CreateRunspace())
{
runspace.Open();
var pipeline = runspace.CreatePipeline();
..
pipeline.Invoke();
..
在安装ApplicationInsights遥测软件包之前,这没有任何问题。版本1.2.x有这个问题所以我升级到2.0.0,但仍然是相同的例外。
下面的Stacktrace:
System.Management.Automation.CmdletInvocationException
的类型初始值设定项 'Microsoft.WindowsAzure.Commands.Common.MetricHelper'扔了一个 例外。 System.Management.Automation.CmdletInvocationException:The 类型初始化器 'Microsoft.WindowsAzure.Commands.Common.MetricHelper'扔了一个 例外。 ---> System.TypeInitializationException:类型 'Microsoft.WindowsAzure.Commands.Common.MetricHelper'的初始化程序 抛出一个例外。 ---> System.Reflection.TargetInvocationException: 调用的目标抛出了异常。 ---> System.InvalidOperationException:Type “Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector,Version = 2.0.0.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35'未实现所需 接口 Microsoft.ApplicationInsights.Extensibility.ITelemetryModule。在 Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.CreateInstance(类型 interfaceType,String typeName)at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstance(的XElement 定义,类型expectedType,对象实例)at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstances [T](的XElement 定义,ICollection`1实例)---内部异常结束 堆栈跟踪---在System.RuntimeMethodHandle.InvokeMethod(对象 target,Object [] arguments,Signature sig,Boolean constructor)at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object []参数,Object []参数)at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object []参数,CultureInfo文化)
在 Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstance(的XElement 定义,类型expectedType,对象实例)at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadProperties(的XElement instanceDefinition,Object instance)at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstance(的XElement 定义,类型expectedType,对象实例)at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.Initialize(TelemetryConfiguration 配置) Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.get_Active() 在Microsoft.ApplicationInsights.TelemetryClient..ctor()at Microsoft.WindowsAzure.Commands.Common.MetricHelper..cctor()--- 内部异常堆栈跟踪结束--- at Microsoft.WindowsAzure.Commands.Common.MetricHelper.GenerateSha256HashString(字符串 originInput)at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.InitializeQosEvent() 在 Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.BeginProcessing() 在 Microsoft.WindowsAzure.Commands.Utilities.Profile.SubscriptionCmdletBase.BeginProcessing() 在System.Management.Automation.Cmdlet.DoBeginProcessing()at System.Management.Automation.CommandProcessorBase.DoBegin()---结束 内部异常堆栈跟踪--- at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable的 输入)
现在我卸载了ApplicationInsights的NuGet包,因为我不知道解决方案。也许这是ApplicationInsights中的一个错误?