I have the following script that loads the ApplicationInsights DLL from the 2.22 DLL. Everything works except the last call of the StartOperation Extension method.
I would appreciate any ideas.
`
$ApplicationInsightsDllLocation = "B:\Microsoft.ApplicationInsights.dll"
if (-not (([AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.Location -like "applicationinsights.2.22." }).Count -eq 1)) {
[Reflection.Assembly]::LoadFile($ApplicationInsightsDllLocation)
}
$TelemetryConfiguration = [Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration]::new()
$TelemetryConfiguration.ConnectionString = Get-ConnectionString
$TelemetryClient = [Microsoft.ApplicationInsights.TelemetryClient]::new($TelemetryConfiguration)
#This call works
$TelemetryClient.TrackEvent("Event Name")
#This call fails with the following error
$Operation = [Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetryExtensions]::StartOperation($TelemetryClient, "Operation Name")
<#
InvalidOperation: B:\Telemetry\Telemetry.ps1:34:22
Line |
34 | … Operation = [Microsoft.ApplicationInsights.Extensibility.Implementati …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Unable to find type [Microsoft.ApplicationInsights.Extensibility.Implementation.OperationTelemetryExtensions].
#>
`