Share via

Nullreference exeption in AddApplicationInsightsTelemetryWorkerService

Martin Vollmer 1 Reputation point
2021-08-26T12:15:55.743+00:00

In a .dll I have a method to send an Azure Application Event. The method contains the following lines:

        TelemetryConfiguration configuration = new TelemetryConfiguration(orchestrationKeyToUse);
        IServiceCollection services = new ServiceCollection();

        services.AddSingleton<ITelemetryInitializer, KnaufCustomTelemetryInitializer>();
        services.AddApplicationInsightsTelemetryWorkerService(orchestrationKeyToUse);
        services.AddApplicationInsightsTelemetryProcessor<KnaufCustomTelemetryProcessor>();

When I call the method from an exe, there is no problem.
When I call the method in an interface method of an addin, it throws an Nullreference-Exception in AddApplicationInsightsTelemetryWorkerService.
I tried to start a thread and call the method in the thread, but it throws the Nullreference-Exception there, too.
What could be the reason?

Azure Monitor
Azure Monitor

An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.