Avalonia
Avalonia copied to clipboard
Null reference exception on iOS when using TryGetWellKnownFolderAsync
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:
- Clone the example repository [email protected]:LongoMatch/AvaloniaiOSGetFolderError.git
- Run the iOS application
- Click on the button that appears in the center of the screen
- 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