Object reference not set on GetOcurrences()

I’m testing DHTMLX Scheduler .NET before buying it and I want te get all Recurring events on a specific Day.

Here is my code :

var from = new DateTime(2016, 3, 26);
var to = new DateTime(2016, 3, 28);

        var testEvent = new CalendarEvent() {
            start_date = new DateTime(2016, 3, 27,12,0,0),
            end_date = new DateTime(2016,3, 27,20,0,0),
            event_length = null,
            event_pid = null,
            id = 0,
            rec_type = "",
            text = "Test event"

        var events = new List<CalendarEvent>() { testEvent };
        var helper = new DHXEventsHelper();
        var events2 = helper.GetOccurrences(events, from, to);[/code]

Here is the CalendarEvent :

public class CalendarEvent { public int id { get; set; } public string text { get; set; } public DateTime? start_date { get; set; } public DateTime? end_date { get; set; } public long? event_length { get; set; } public string rec_type { get; set; } public int? event_pid { get; set; } }

And the error :
[NullReferenceException: Object reference not set to an instance of an object.]
DHTMLX.Common.DHXEventsHelper.b__1(_ParsedEventData e) +35
System.Linq.WhereListIterator1.MoveNext() +73 System.Collections.Generic.List1…ctor(IEnumerable1 collection) +381 System.Linq.Enumerable.ToList(IEnumerable1 source) +58
DHTMLX.Common.DHXEventsHelper.GetOccurrences(IEnumerable items, DateTime from, DateTime to) +1003

thanks you


Curently “GetOccurrences” method works only with recurring events. It seems like your event isn’t recurring. (rec_type == “”).
Try to use it with recurring events, it should work.

It does seem like a bug in the helper, it should not throw an error if there are non-recurring events in a dataset.
We’ll publish an update soon

The issue should be fixed in the latest NuGet build nuget.org/packages/DHTMLX.S … T/

wow, thank you ! I’m really impress by your service.