For an application on which I'm working, I want to export all appointments from a ScheduleView to an ICalendar format. By following the ICal example provided in the WPF Q2 2011 Demos, I have been able to successfully export all of my appointments using the AppointmentCalendarExporter.
My next step was to create some exceptions to a recurring appointment, and try to export those. This is where I ran into some problems. If I create an exception which simply excludes an occurrence of a recurring appointment, then I can still export the recurring appointment to an ICalendar format (file or string), and the exclusion is represented in the ICal content like so: "EXDATE:20110923T050000". However, if I create an exception in which I change the time of an occurrrence of a recurring appointment (per the example here), then attempting to export the appointment to an ICal format results in a StackOverflowException.
Any idea what's going on here?
My next step was to create some exceptions to a recurring appointment, and try to export those. This is where I ran into some problems. If I create an exception which simply excludes an occurrence of a recurring appointment, then I can still export the recurring appointment to an ICalendar format (file or string), and the exclusion is represented in the ICal content like so: "EXDATE:20110923T050000". However, if I create an exception in which I change the time of an occurrrence of a recurring appointment (per the example here), then attempting to export the appointment to an ICal format results in a StackOverflowException.
Any idea what's going on here?
3 Answers, 1 is accepted
0
Hello Paul,
This problem does not appear at our side.Please see the attached movie for a reference. Is it possible to send us sample project to illustrate the issue? We will test it locally and give you more details.
Best wishes,
Rosi
the Telerik team
This problem does not appear at our side.Please see the attached movie for a reference. Is it possible to send us sample project to illustrate the issue? We will test it locally and give you more details.
Best wishes,
Rosi
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Paul
Top achievements
Rank 1
answered on 22 Sep 2011, 06:03 PM
I think I may have found what the underlying problem is, but I will need your help to figure out how to address it. I went back to try to test this issue using the same steps I was using the other day, and I now realize that I'm getting a different exception before I ever get to the StackOverflowException I reported. Specifically, I'm getting an ArgumentOutOfRangeException which is being thrown from a DateTime method with the following message and (abbreviated) stack trace:
The added or subtracted value results in an un-representable DateTime.
Parameter name: value
This exception occurs not just once, but repeatedly -- WAY too many times for me to want to count -- after I execute the following block of code:
...where appointments is defined as an ObservableCollection<IAppointment> and is bound to the RadScheduleView and where the Copy method of JobConfiguration is defined as follows:
Upon looking more closely at the local values for methods on the stack, I observe some things that don't look right to me:
For method...
Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleViewBase.GetExceptionsForReccurringAppointments.AnonymousMethod__7e(Telerik.Windows.Controls.ScheduleView.IAppointment a = {AWL.Taskmaster.JobManagerGui.UserControls.JobConfiguration}) Line 2475 + 0x4b bytes
...its value for range is...
{Start: 10/9/2011 12:00:00 AM, End: 12/31/9999 11:59:59 PM} Telerik.Windows.Controls.ScheduleView.IDateSpan
And looking a few methods higher on the stack, I have method
Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleView.RecurrencePattern.GetOccurrences(System.DateTime start = {System.DateTime}, System.DateTime from = {System.DateTime}, System.DateTime to = {System.DateTime}) Line 345 + 0x6b bytes
My only explanation for not seeing these ArgumentOutOfRangeException exceptions the other day was because I must have temporarily disabled the Visual Studio debugger option to break when a CLR exception is thrown. (I sometimes will disable this.) But I always have the option enabled to break when a CLR exception is user-unhandled, which is what the StackOverflowException triggered.
If I disable breaking on thrown exceptions, then I get through the storm of ArgumentOutOfRangeExceptions that are thrown after adding the new appointment. However, nearly all UI interactions on the RadScheduleView thereafter are TERRIBLY slow. If I re-enable the debugger option to break on thrown CLR exceptions, I immediately see that when my mouse even enters the client area of RadScheduleView, I start getting those ArgumentOutOfRangeExceptions again.
If the debugger option to break on thrown exceptions is left disabled, then changing the time of an occurrence of a recurrent appointment, and then exporting that appointment will result in the StackOverflowException I reported earlier.
Where do I go from here?
The added or subtracted value results in an un-representable DateTime.
Parameter name: value
- mscorlib.dll!System.DateTime.AddTicks(long value) + 0xe3 bytes
- mscorlib.dll!System.DateTime.Add(double value = 2917647.0, int scale) + 0x89 bytes
- mscorlib.dll!System.DateTime.AddDays(double value) + 0x14 bytes
- Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleView.RecurrencePattern.GetNextDate(System.DateTime start = {System.DateTime}, int index = 2917647) Line 535 + 0x17 bytes
- Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleView.RecurrencePattern.GetOccurrences(System.DateTime start = {System.DateTime}, System.DateTime from = {System.DateTime}, System.DateTime to = {System.DateTime}) Line 345 + 0x6b bytes
- mscorlib.dll!System.Collections.Generic.List<System.DateTime>.List(System.Collections.Generic.IEnumerable<System.DateTime> collection) + 0xdd bytes
- System.Core.dll!System.Linq.Enumerable.ToList<System.DateTime>(System.Collections.Generic.IEnumerable<System.DateTime> source) + 0x20 bytes
- Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleView.AppointmentExtensions.GetOccurrencesWithoutExceptionsFromDateTimeRange(Telerik.Windows.Controls.ScheduleView.IAppointment appointment = {AWL.Taskmaster.JobManagerGui.UserControls.JobConfiguration}, System.DateTime from = {System.DateTime}, System.DateTime to = {System.DateTime}) Line 67 + 0x7e bytes
- Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleViewBase.GetExceptionsForReccurringAppointments.AnonymousMethod__7e(Telerik.Windows.Controls.ScheduleView.IAppointment a = {AWL.Taskmaster.JobManagerGui.UserControls.JobConfiguration}) Line 2475 + 0x4b bytes
- System.Core.dll!System.Linq.Enumerable.SelectManyIterator<Telerik.Windows.Controls.ScheduleView.IAppointment,Telerik.Windows.Controls.ScheduleView.Occurrence>.MoveNext() + 0xef bytes
- System.Core.dll!System.Linq.Enumerable.WhereEnumerableIterator<Telerik.Windows.Controls.ScheduleView.Occurrence>.MoveNext() + 0x58 bytes
- System.Core.dll!System.Linq.Enumerable.Any<Telerik.Windows.Controls.ScheduleView.Occurrence>(System.Collections.Generic.IEnumerable<Telerik.Windows.Controls.ScheduleView.Occurrence> source) + 0x54 bytes
- Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleViewBase.HasAppointmentsInRange(Telerik.Windows.Controls.ScheduleView.IDateSpan range = {Telerik.Windows.Controls.ScheduleView.DateSpan}, bool skipIntersectedWithTheRangeAppointments = true, bool moveForward = true, Telerik.Windows.Controls.ScheduleView.DateTimeInterval interval = {Telerik.Windows.Controls.ScheduleView.DateTimeInterval}) Line 1395 + 0xdd bytes
- Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleViewBase.OnQueryGoToNextAppointmentCanExecuted(object sender = {Telerik.Windows.Controls.RadScheduleView}, System.Windows.Input.CanExecuteRoutedEventArgs e = {System.Windows.Input.CanExecuteRoutedEventArgs}) Line 347 + 0x95 bytes
This exception occurs not just once, but repeatedly -- WAY too many times for me to want to count -- after I execute the following block of code:
var jc =
new
JobConfiguration();
jc.Start = DateTime.Today.AddHours(5);
jc.End = DateTime.Today.AddHours(5.5);
jc.Subject =
"Batch Job with Exceptions"
;
var rp =
new
RecurrencePattern();
rp.Frequency = RecurrenceFrequency.Weekly;
rp.DaysOfWeekMask = RecurrenceDays.Monday | RecurrenceDays.Wednesday | RecurrenceDays.Friday;
var rr =
new
RecurrenceRule(rp);
jc.RecurrenceRule = rr;
DateTime? nextOccurrence = DateTime.Now;
// Simply Exclude
nextOccurrence = rp.GetFirstOccurrence(nextOccurrence.Value.AddDays(3));
nextOccurrence = nextOccurrence.Value.Date + jc.Start.TimeOfDay;
rr.AddException(nextOccurrence.Value);
// Change to different time on the same day
nextOccurrence = rp.GetFirstOccurrence(nextOccurrence.Value.AddDays(5));
nextOccurrence = nextOccurrence.Value.Date + jc.Start.TimeOfDay;
var altAppt = jc.Copy();
altAppt.Start = (nextOccurrence.Value.Date + altAppt.Start.TimeOfDay).AddHours(1.5);
altAppt.End = altAppt.Start.AddHours(0.5);
rr.AddException(nextOccurrence.Value, altAppt);
appointments.Add(jc);
...where appointments is defined as an ObservableCollection<IAppointment> and is bound to the RadScheduleView and where the Copy method of JobConfiguration is defined as follows:
public
IAppointment Copy()
{
var jc =
new
JobConfiguration();
jc.Subject = Subject;
jc.Start = Start;
jc.End = End;
jc.RecurrenceRule = RecurrenceRule;
return
jc;
}
Upon looking more closely at the local values for methods on the stack, I observe some things that don't look right to me:
For method...
Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleViewBase.GetExceptionsForReccurringAppointments.AnonymousMethod__7e(Telerik.Windows.Controls.ScheduleView.IAppointment a = {AWL.Taskmaster.JobManagerGui.UserControls.JobConfiguration}) Line 2475 + 0x4b bytes
...its value for range is...
{Start: 10/9/2011 12:00:00 AM, End: 12/31/9999 11:59:59 PM} Telerik.Windows.Controls.ScheduleView.IDateSpan
And looking a few methods higher on the stack, I have method
Telerik.Windows.Controls.ScheduleView.dll!Telerik.Windows.Controls.ScheduleView.RecurrencePattern.GetOccurrences(System.DateTime start = {System.DateTime}, System.DateTime from = {System.DateTime}, System.DateTime to = {System.DateTime}) Line 345 + 0x6b bytes
...which has a
candidateIndex of 2917648 and
occurrencesCount of 1250421. It apparently keeps calling the GetNexDate method of RecurrencePattern with the start date of the range and the current candidate index in order to calculate a new DateTime, and when the index reaches too high a value (e.g. 2,917,648 in my case), an ArgumentOutOfRangeException results.
What's going on here? (If I had the source code, I could better assess what's going on, but the debugger is all I have.) Why is it necessary to determine ALL occurrences until 12/31/9999? Am I doing something wrong, or is this some weirdness with the API? The API clearly could stop me from doing something really stupid like this much earlier on, but it's clearly not.
What's going on here? (If I had the source code, I could better assess what's going on, but the debugger is all I have.) Why is it necessary to determine ALL occurrences until 12/31/9999? Am I doing something wrong, or is this some weirdness with the API? The API clearly could stop me from doing something really stupid like this much earlier on, but it's clearly not.
My only explanation for not seeing these ArgumentOutOfRangeException exceptions the other day was because I must have temporarily disabled the Visual Studio debugger option to break when a CLR exception is thrown. (I sometimes will disable this.) But I always have the option enabled to break when a CLR exception is user-unhandled, which is what the StackOverflowException triggered.
If I disable breaking on thrown exceptions, then I get through the storm of ArgumentOutOfRangeExceptions that are thrown after adding the new appointment. However, nearly all UI interactions on the RadScheduleView thereafter are TERRIBLY slow. If I re-enable the debugger option to break on thrown CLR exceptions, I immediately see that when my mouse even enters the client area of RadScheduleView, I start getting those ArgumentOutOfRangeExceptions again.
If the debugger option to break on thrown exceptions is left disabled, then changing the time of an occurrence of a recurrent appointment, and then exporting that appointment will result in the StackOverflowException I reported earlier.
Where do I go from here?
0
Hello Paul,
Thank you for sending the explanation.
We've tested the provided code with the latest Q2 SP1 release but weren't able to reproduce these exceptions, I've attached our test project for a reference, could you please download it and give it a try?
We're repeating all the occurrences until DateTime.MaxValue - this is exactly "12/31/9999", but you can set a different end date as demonstrated here.
Greetings,
Yana
the Telerik team
Thank you for sending the explanation.
We've tested the provided code with the latest Q2 SP1 release but weren't able to reproduce these exceptions, I've attached our test project for a reference, could you please download it and give it a try?
We're repeating all the occurrences until DateTime.MaxValue - this is exactly "12/31/9999", but you can set a different end date as demonstrated here.
Greetings,
Yana
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>