C# iOS 9.3中的文件选择器异常

C# iOS 9.3中的文件选择器异常,c#,xamarin,xamarin.ios,ios9.3,C#,Xamarin,Xamarin.ios,Ios9.3,试图在运行iOS 9.3的设备上实现文件选择器 这些功能在authentications.plist中打勾,代码在运行iOS 12.2的模拟设备上运行。还尝试模拟其他运行iOS 9.3的设备,结果是一样的 using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Fo

试图在运行iOS 9.3的设备上实现文件选择器

这些功能在authentications.plist中打勾,代码在运行iOS 12.2的模拟设备上运行。还尝试模拟其他运行iOS 9.3的设备,结果是一样的

using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Plugin.FilePicker;
using System.Diagnostics;

namespace CrossfileTest
{

    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private async void BrowseBtn_Clicked(object sender, EventArgs e)
        {
            try
            {
                var file = await CrossFilePicker.Current.PickFile();
                Debug.WriteLine("this file " + file.FileName);
            }
            catch(Exception ex)
            {
                Debug.WriteLine("it blew up! " + ex);
            }
        }
    }
}```

This is the exception I get on iOS 9.3:
  at CrossfileTest.MainPage.BrowseBtn_Clicked (System.Object sender, System.EventArgs e) [0x00029] in C:\Users\UserName\source\repos\CrossfileTest\CrossfileTest\CrossfileTest\MainPage.xaml.cs:27  0   CoreFoundation                      0x000000010bba4d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010c520deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010bba4bea +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x000000010a7fcd5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
    4   UIKit                               0x00000001093485c5 -[UIDocumentPickerViewController _commonInitWithCompletion:] + 370
    5   UIKit                               0x000000010934a442 -[UIDocumentPickerViewController initWithDocumentTypes:inMode:] + 411
    6   CrossfileTest.iOS                   0x0000000102c25539 xamarin_dyn_objc_msgSend + 217
    7   ???                                 0x000000011f6039ee 0x0 + 4821367278

Ideas on how to fix this?

这显然是插件内部的崩溃。您可以将问题发布到他们的github上,以便修复


在iOS 9和iOS 12上,
UIDocumentPickerViewController
的工作方式有所不同,因此,如果它在一个而不是另一个上工作,没有什么特别奇怪的。

UIDocumentPickerViewController
在iOS 9和iOS 12上有两个不同的事件,这一定是导致问题的原因。如果在一个文档上选择了两个不同的事件,那么,解决方案就是询问其他地方以得出结论,您的另一个选择是使用本机代码,自己为iOS和Android实现选择器,或者修复插件代码,因为它是开源的。对于您当前的级别来说,这可能有点太高级了,因此您最好报告问题并等待解决。