ApplicationInsights-dotnet icon indicating copy to clipboard operation
ApplicationInsights-dotnet copied to clipboard

Xamarin Forms Android fails due to AppDomain.CurrentDomain.BaseDirectory

Open jmichas opened this issue 3 years ago • 1 comments

Describe the bug

When using Microsoft.ApplicationInsights 2.12.0 on Xamarin Forms Android with Serilog.Sinks.ApplicationInsights configuring a Sink fails because on line 58 in file https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/BASE/src/Microsoft.ApplicationInsights/Extensibility/Implementation/Platform/PlatformImplementation.cs there is this: configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApplicationInsights.config"); AppDomain.CurrentDomain.BaseDirectory is null on Android. I guess the Android project does not get caught in the #if NETSTANDARD on line 40 so when the read xml code runs it fails.

Probably could either add a catch for the exception thrown if path1 on Path.Combine is null or change the #if to include Android projects.

To Reproduce

Create a self-contained project using the template of your choice, apply the minimum required code to result in the issue you're observing.

We will close this issue if:

  • The repro project you share with us is complex. We can't investigate custom projects, so don't point us to such, please.
  • If we will not be able to repro the behavior you're reporting

For Immediate Support

For immediate support relating to the Application Insights .NET SDK we encourage you to file an Azure Support Request with Microsoft Azure instead of filing a GitHub Issue in this repository. You can do so by going online to the Azure portal and submitting a support request. Access to subscription management and billing support is included with your Microsoft Azure subscription, and technical support is provided through one of the Azure Support Plans. For step-by-step guidance for the Azure portal, see How to create an Azure support request. Alternatively, you can create and manage your support tickets programmatically using the Azure Support ticket REST API

jmichas avatar Aug 21 '21 02:08 jmichas

Making things worse, this continues to fire every 10 seconds or so which makes debugging Android projects nearly impossible.

lafritay avatar Feb 24 '22 15:02 lafritay

This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.

github-actions[bot] avatar Dec 22 '22 00:12 github-actions[bot]