Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Null reference exception on iOS when using TryGetWellKnownFolderAsync

Open dfernandezramos opened this issue 1 year ago • 0 comments

Describe the bug

Obtaining the application storage provider and then calling TryGetWellKnownFolderAsync method leads to an unhandled exception when running on iOS.

To Reproduce

Steps to reproduce the behavior:

  1. Clone the example repository [email protected]:LongoMatch/AvaloniaiOSGetFolderError.git
  2. Run the iOS application
  3. Click on the button that appears in the center of the screen
  4. See the error

Expected behavior

The method should return the well known directory or null in case it does not exist. Without crashing.

Environment

  • OS: iOS 17.2
  • Avalonia-Version: 11.0.9

Additional context

System.ArgumentNullException: Value cannot be null. (Parameter 'url')
   at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle)
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at AvaloniaApplication1.iOS.Application.Main(String[] args) in /Users/dfernandez/Development/AvaloniaApplication1/AvaloniaApplication1/AvaloniaApplication1.iOS/Main.cs:line 12
2024-02-15 12:22:59.319744+0100 AvaloniaApplication1.iOS[45672:357451] Unhandled managed exception: Value cannot be null. (Parameter 'url') (System.ArgumentNullException)
   at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle)
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at AvaloniaApplication1.iOS.Application.Main(String[] args) in /Users/dfernandez/Development/AvaloniaApplication1/AvaloniaApplication1/AvaloniaApplication1.iOS/Main.cs:line 12

dfernandezramos avatar Feb 15 '24 11:02 dfernandezramos