We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

System.InvalidOperationException: Sequence contains no elements - SfSchedule

Update: Tested with 17.4.0.39, issue still occurs.

I am getting an intermittent issue with SfSchedule on Xamarin Forms - Android.

For some reason, the SfSchedule sometimes throws the following exception (on Android only):

Thread started: #16
12-17 10:17:00.243 I/MonoDroid(27268): UNHANDLED EXCEPTION:
12-17 10:17:00.256 I/MonoDroid(27268): System.InvalidOperationException: Sequence contains no elements
12-17 10:17:00.256 I/MonoDroid(27268):   at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00010] in <10a59ea148cd4c6face8252c32c5e77b>:0
12-17 10:17:00.256 I/MonoDroid(27268):   at Com.Syncfusion.Schedule.AppointmentEngine.GetVisibleAppointments (System.Collections.ObjectModel.ObservableCollection`1[T] visibleDateRange, Com.Syncfusion.Schedule.ScheduleAppointmentCollection appointments, System.Boolean isTimelineView) [0x0000e] in :0
12-17 10:17:00.256 I/MonoDroid(27268):   at Com.Syncfusion.Schedule.SfSchedule.b__319_0 () [0x00035] in :0
12-17 10:17:00.256 I/MonoDroid(27268):   at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <46c2fa109b574c7ea6739f9fe2350976>:0
12-17 10:17:00.256 I/MonoDroid(27268):   at System.Threading.Tasks.Task.Execute () [0x00000] in <46c2fa109b574c7ea6739f9fe2350976>:0
12-17 10:17:00.256 I/MonoDroid(27268): --- End of stack trace from previous location where exception was thrown ---
12-17 10:17:00.256 I/MonoDroid(27268):
12-17 10:17:00.256 I/MonoDroid(27268):   at Com.Syncfusion.Schedule.SfSchedule.UpdateResourceAppointments (System.Collections.ObjectModel.ObservableCollection`1[T] resourceIDColl) [0x000ac] in :0
12-17 10:17:00.256 I/MonoDroid(27268):   at System.Runtime.CompilerServices.AsyncMethodBuilderCore <>c.b__7_0 (System.Object state) [0x00000] in <46c2fa109b574c7ea6739f9fe2350976>:0
12-17 10:17:00.256 I/MonoDroid(27268):   at Android.App.SyncContext <>c__DisplayClass2_0.b__0 () [0x00000] in <8c07a09624c14764b43f6b946a5a1f23>:0
12-17 10:17:00.256 I/MonoDroid(27268):   at Java.Lang.Thread RunnableImplementor.Run () [0x00008] in <8c07a09624c14764b43f6b946a5a1f23>:0
12-17 10:17:00.256 I/MonoDroid(27268):   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <8c07a09624c14764b43f6b946a5a1f23>:0
12-17 10:17:00.256 I/MonoDroid(27268):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.79(intptr,intptr)

The code I use to set the ScheduleResources, DataSource, and SelectedResources:


            this.schedule.ScheduleResources = this.VM.Resources;
            this.schedule.DataSource = this.VM.Sessions;
            this.schedule.SelectedResources = this.VM.SelectedResources;

Where this.schedule is an SfSchedule on a XAML page. VM.Resources is an ObservableCollection<object>, same with SelectedResources, and Sessions is a ScheduleAppointmentCollection.

Any guidance would be appreciated. This is a show-stopper for us.


4 Replies

EP Elias P December 17, 2019 09:58 AM

Update: I decided to try the following sequence:

            this.schedule.SuspendAppointmentUpdate();
            this.schedule.DataSource = this.VM.Sessions;
            this.schedule.ScheduleResources = this.VM.Resources;
            this.schedule.SelectedResources = this.VM.SelectedResources;
            this.schedule.ResumeAppointmentUpdate();

At the moment this seems to have resolved the issue. I am continuing to investigate.


IR Indumathi Ravichandran Syncfusion Team December 18, 2019 04:51 AM

Hi Elias, 
 
Thank you for contacting Syncfusion support. 
 
Based on the last update, we hope that issue has been resolved at you end.  In the meantime, we are validating the root cause for the mentioned exception in source level. We will wait to hear from you after the investigation. 
 
Please get in touch with us if you would require any further assistance. 
 
Regards, 
Indumathi R 



AB Alessandro Bellotti replied to Elias P March 20, 2020 02:03 PM

Update: I decided to try the following sequence:

            this.schedule.SuspendAppointmentUpdate();
            this.schedule.DataSource = this.VM.Sessions;
            this.schedule.ScheduleResources = this.VM.Resources;
            this.schedule.SelectedResources = this.VM.SelectedResources;
            this.schedule.ResumeAppointmentUpdate();

At the moment this seems to have resolved the issue. I am continuing to investigate.

Hello,
this workaround don't work for me.
There is any update about this issue ?
 


SS SaiGanesh Sakthivel Syncfusion Team March 23, 2020 04:26 AM

Hi Alessandro, 
 
Thank you for the update. 
 
We have checked the reported issueSystem.InvalidOperationException from our end. We regret to inform that the issue is not replicated from our side. We have attached the test sample in the following link. 
 
 
let us know it you still facing the same issue. If not, could you please share the following details which would be helpful for us to check on it and provide you the solution at the earliest.  
 
·       Modify our sample / Share layouts used in Xaml page 
·       Synfusion and Xamarin Forms updated version 
 
Regards, 
SaiGanesh Sakthivel 


Loader.
Live Chat Icon For mobile
Up arrow icon