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

null reference exception when adding a seccond appointment in SfSchedule

i want to add som reccurring appointments to an SfSchedule Control, it accept the dirst appointment that i put in it, but when i want to add a second one it gives me a null reference exception.

this is my code:

var appointment = ((Horarios.BindingClass) DataContext).Appointment as ScheduleAppointment ??
                              new ScheduleAppointment();

            RecurrenceProperties RecProp = new RecurrenceProperties
                RecurrenceType = RecurrenceType.Weekly,
                IsRangeRecurrenceCount = false,
                IsRangeNoEndDate = true,
                IsRangeEndDate = false,


            switch (((Horarios.BindingClass)DataContext).CurrentSelectedDate.Value.DayOfWeek)
                case DayOfWeek.Sunday:
                case DayOfWeek.Monday:
                    RecProp.IsWeeklyMonday = true;
                case DayOfWeek.Tuesday:
                    RecProp.IsWeeklyTuesday = true;
                case DayOfWeek.Wednesday:
                    RecProp.IsWeeklyWednesday = true;
                case DayOfWeek.Thursday:
                    RecProp.IsWeeklyThursday = true;
                case DayOfWeek.Friday:
                    RecProp.IsWeeklyFriday = true;
                case DayOfWeek.Saturday:

                    RecProp.IsWeeklySaturday = true;
                    throw new ArgumentOutOfRangeException();

            appointment.StartTime = StartTime.DateTime.Value;
            appointment.EndTime = EndTime.DateTime.Value;
            appointment.RecurrenceRule = ScheduleHelper.RRuleGenerator(RecProp,
            appointment.StartTime, appointment.EndTime);
            appointment.IsRecursive = false;

i always get  a null reference exception on the last line when i'm addin a second appointment, does not matter if it is a recurrent appointment or not.

1 Reply

SP Sivakumar Punniya Moorthi Syncfusion Team August 18, 2017 07:27 PM UTC

Hi Jesus, 

Thanks for using Syncfusion products. 

We had prepared a sample with the provided code snippet. Can you please provide as the following information?  So that we could provide you the prompt solution. 
1.      Version of SfSchedule.WPF.dll 
2.      .Net framework used. 
3.      Screen shot or stack trace of the Exception occurred. 

Sample Link :  ScheduleApp

Sivakumar P 

Live Chat Icon For mobile
Up arrow icon