dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 531 forks source link

The value of AppContext.BaseDirectory is null #3489

Open tomstreet opened 5 years ago

tomstreet commented 5 years ago

Steps to Reproduce

  1. File > New > Android App
  2. Add var d = AppContext.BaseDirectory; to the top of OnCreate in MainActivity
  3. Add breakpoint to that line
  4. Run on Android 8.1 emulator and observe that the value of AppContext.BaseDirectory is null.

I initially came across this while trying to use the new HostBuilder from AspNetCore to get DI, Logging and HttpClientFactory (which works fine on iOS) and I logged an issue with in the AspNetCore repo but it looks like it might be a Xamarin Android issue.

Expected Behavior

I expected this to be something other than null

Version Information

Microsoft Visual Studio Enterprise 2019 Version 16.2.1 VisualStudio.16.Release/16.2.1+29201.188 Microsoft .NET Framework Version 4.8.03752

Installed Version: Enterprise

Visual C++ 2019 00433-90050-37848-AA233 Microsoft Visual C++ 2019

Application Insights Tools for Visual Studio Package 9.1.00611.1 Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019 16.2.290.48383 ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019 16.2.290.48383 For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.2.290.48383 Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.2.290.48383 Azure Functions and Web Jobs Tools

C# Tools 3.2.0-beta4-19359-03+15b43b33901c88f68ef43f8314b5a2457716780d C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.2.0 (d16-2@8b56e20) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info

Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 0x10 - v2.9.20626.2

Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 1.0 Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 16.2.6 (4cfc7c3) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.2.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

Snapshot Debugging Extension 1.0 Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.61906.28070 Microsoft SQL Server Data Tools

TypeScript Tools 16.0.10627.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.2.0-beta4-19359-03+15b43b33901c88f68ef43f8314b5a2457716780d Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6 16.2.0-beta.19321.1+a24d94ecf97d0d69d4fbe6b8b10cd1f97737fff4 Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

Xamarin 16.2.0.91 (d16-2@2983aebeb) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.2.0.375 (remotes/origin/d16-2@357d38ef4) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.3.117 (59a59e8) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 9.4.1.0 (d16-2/ebd65c9) Xamarin.Android Reference Assemblies and MSBuild support. Mono: mono/mono/2019-02@e6f5369c2d2 Java.Interop: xamarin/java.interop/d16-2@d64ada5 LibZipSharp: grendello/LibZipSharp/d16-2@caa0c74 LibZip: nih-at/libzip/rel-1-5-1@b95cf3f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-2@6f6c969

Xamarin.iOS and Xamarin.Mac SDK 12.14.0.114 (c669116) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

neyugnluan commented 4 years ago

Is there any progress on this issue? or any workaround? facing the problem 1-year plus.