繁体   English   中英

UWP 应用程序由于 Xamarin.CarouselView 而崩溃 Xamarin ZADD4E130E8FD245A30CDED0AB105 项目

[英]UWP app is crashing due to Xamarin.CarouselView in Xamarin UWP project

以下是错误:

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)

这是在库问题中注册的 CarouselView 控件 UWP 渲染器中的错误: https://github.com/alexrainman/CarouselView/issues/526

就我而言,我在一个管理应用程序中遇到了这个崩溃,这是我独家开发的解决方案的一部分。 让我对此感到好奇的是,最终用户应用程序不存在这个问题。 所有解决方案都是由我编写的,使用相同的技术、库等。

所以我开始分解管理应用程序,通过将其与最终用户应用程序代码进行比较来了解崩溃。 我得出的结论是,在 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 渲染器无法处理的一些意想不到的 state。

此外,几年前我开始使用这个库,当时 Xamarin.Forms 中没有类似的控件。 现在我们有 CarouselView: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/carouselview/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM