由于Xamarin UWP项目中的Xamarin.CarouselView,导致UWP应用崩溃。

问题描述 投票:0回答:1

以下是错误。

System.ArgumentException: Delegate to an instance method cannot have null 'this'.
   at System.MulticastDelegate.ThrowNullThisInDelegateToInstance()
   at CarouselView.FormsPlugin.UWP.CarouselViewRenderer.FlipView_Loaded(Object sender, RoutedEventArgs e)
c# xamarin.uwp
1个回答
0
投票

这是CarouselView控件UWP渲染器中的一个错误,它是在库问题中注册的。https:/github.comalexrainmanCarouselViewissues526。.

在我的情况下,我在一个管理应用程序中得到了这个崩溃,这是由我独家开发的解决方案的一部分。让我好奇的是,终端用户的应用并没有出现这个问题。所有的解决方案都是我自己编写的,使用的是相同的技术、库等等等等。

所以我开始分解管理员应用,通过与最终用户应用代码的比较来了解崩溃的原因。我得出的结论是,崩溃的原因是在OnAppearing时,对被设置为控件的ItemSource的列表进行了明确的调用。

public ProductPage(string productId)
{
    InitializeComponent();

    this.productId = productId;

    this.products = new ObservableCollection<ProductGalleryDTO>();
    this.ProductGallery.ItemsSource = this.products;
}

protected override void OnAppearing()
{
    base.OnAppearing();

    // Note: this causes the issue in my case
    //this.products.Clear();

    this.GetProductDetails();
}

可能你的崩溃的重现步骤是不同的,因为这应该是一些UWP渲染器无法处理的意外状态。

此外,我在几年前就开始使用这个库,当时Xamarin.Forms中还没有类似的控件。如今我们有了CarouselView。https:/docs.microsoft.comen-usxamarinxamarin-formsuser-interfacecarouselview。

© www.soinside.com 2019 - 2024. All rights reserved.