簡體   English   中英

System.MemberAccessException:無法創建UserNotifications.UNNotificationTrigger的實例,因為它是一個抽象類

[英]System.MemberAccessException: Cannot create an instance of UserNotifications.UNNotificationTrigger because it is an abstract class

我正在使用最新的通知框架UNUserNotificationCenter安排本地通知。

我正在共享一些代碼片段,其中提到了觸發器/訪問觸發器。 請勿順序閱讀。 這只是我閱讀或修改觸發器的代碼片段

var trigger = UNCalendarNotificationTrigger.CreateTrigger(notification.ScheduledTime.DateTimeToNSDateComponents(),false);

trigger.DateComponents.Hour = trigger.DateComponents.Hour + 7;

var觸發器=(UNCalendarNotificationTrigger)(notification.Trigger);

該方法沒有任何編譯錯誤,通知也起作用。 過去幾個月以來,我們在應用商店中都有此代碼。 遲到了,我們看到下面的消息崩潰了。 我沒有在代碼中引用UNNotificationTrigger。 順便說一句,這是xamarin IOS應用程序。

System.MemberAccessException:無法創建UserNotifications.UNNotificationTrigger的實例,因為它是一個抽象類

這是我們正在尋求解決的Xamarin.iOS中的問題。

發生的情況是trigger在某個點消失或被收集,然后重新浮出水面,並且重新鋪裝不知道為此實際隱藏的具體實現,因此您得到了上面的消息。

目前最好的解決方法是在托管代碼中保持指向trigger的指針有效,從而確保永遠不會觸發重鋪表面。

我們在這里跟蹤:

https://github.com/xamarin/xamarin-macios/issues/3935#issuecomment-381200652

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM