microsoft / ApplicationInsights-dotnet

ApplicationInsights-dotnet
MIT License
564 stars 287 forks source link

ApplicationInsights gives error when trying to use ServerTelemetryChannel on iOS on NET MAUI app #2899

Open victorvitanexe opened 3 months ago

victorvitanexe commented 3 months ago

Package used: Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel

Describe the bug

Just try to create a ServerTelemetryChannel in a dotnet Maui app. Works on Android. Crashes on iOS with the current error:

image

To Reproduce

private static void SetupTelemetryClient(MauiAppBuilder appBuilder, AppInsightsConfiguration configuration) { var telemetryConfiguration = new TelemetryConfiguration() { ConnectionString = configuration.ConnectionString }; telemetryConfiguration.TelemetryInitializers.Add(new TelemetryInitializer());

        var channel = new ServerTelemetryChannel
        {
            MaxBacklogSize = configuration.MaxBacklogSize,
            MaxTelemetryBufferCapacity = configuration.MaxTelemetryBufferCapacity,
            MaxTelemetryBufferDelay = configuration.MaxTelemetryBufferDelay,
            MaxTransmissionBufferCapacity = configuration.MaxTransmissionBufferCapacity,
            MaxTransmissionSenderCapacity = configuration.MaxTransmissionSenderCapacity,
            MaxTransmissionStorageCapacity = configuration.MaxTransmissionStorageCapacity,
            StorageFolder = configuration.StorageFolder
        };
        channel.Initialize(telemetryConfiguration);

        telemetryConfiguration.TelemetryChannel = channel;

        _client = new TelemetryClient(telemetryConfiguration);
        appBuilder.Services.AddSingleton(_client);

        Connectivity.ConnectivityChanged += OnConnectivityChanged;
    }