System.ArgumentException when adding viewDefinitions to RadScheduleView

4 posts, 0 answers
  1. Thierry
    Thierry avatar
    22 posts
    Member since:
    Mar 2012

    Posted 29 Nov 2012 Link to this post

    Hello,

    I'm using a RadScheduleView in my project, and it works fine most of the time. But I have had two cases where I get a System.ArgumentException right at the begining when I load my app, whitout being able to do anything about it.

    some details :

    my app opens at first on a screen containing a radScheduleView.
    the radScheduleView is mannulay set to the user's preference (what views he wants, what dayStartTime / dayEndTime, FirstDayOfWeek etc...) in code behind

    so what I do is I clear the ViewDefinitionsCollection and then add exactly the views I want, depending on those settings.

    here is the function that adds the ViewDefinitions :

    /// <summary>
    /// Adds a new ViewDefinition in the Collection
    /// </summary>
    /// <param name="viewDefinitionId">id of the view</param>
    /// <param name="viewDefinitionName">display text for the view (localized)</param>
    private void AddViewDefinition(int viewDefinitionId, string viewDefinitionName)
    {
        ViewDefinitionBase viewDefinition = null;
        int activeViewDefinitionIndex = ScheduleView.ActiveViewDefinitionIndex;
     
        switch (viewDefinitionId)
        {
            case 0: ScheduleView.ViewDefinitions.Add(viewDefinition = new DayViewDefinition { Title = viewDefinitionName, TimerulerMajorTickStringFormat = "{0:t}     " }); break;
            case 1: ScheduleView.ViewDefinitions.Add(viewDefinition = new WeekViewDefinition { Title = viewDefinitionName, TimerulerMajorTickStringFormat = "{0:t}     " }); break;
            case 2: ScheduleView.ViewDefinitions.Add(viewDefinition = new WeekViewDefinition
                        {
                            Title = viewDefinitionName,
                            TimerulerMajorTickStringFormat = "{0:t}     ",
                            GroupFilter = obj =>
                            {
                                if (obj is DateTime)
                                {
                                    var day = ((DateTime)obj).DayOfWeek.GetRecurrenceDay();
                                    return (day & WorkingDays) == day;
                                }
                                return true;
                            }
                        }); break;
            case 3: ScheduleView.ViewDefinitions.Add(viewDefinition = new MonthViewDefinition { Title = viewDefinitionName }); break;
        }
     
        if (viewDefinition == null) return;
     
        viewDefinition.SetValue(IdProperty, viewDefinitionId);
        viewDefinition.SetValue(DayViewDefinition.EnableSmallAppointmentRenderingProperty, true);
     
        ScheduleView.ActiveViewDefinitionIndex = activeViewDefinitionIndex;
    }

    and the Issue I have seems to lies within this function (see attached screenshot for details on the exception)

    do you have any idea what is happening here? (I don't)


    as far as I can tell, this code should work fine to add new ViewDefinitions to the collection, but for whatever reason I get this Exception. I could catch it and move on but then again, I'd rather know what goes wrong than try to ignore it.

    thanks
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 04 Dec 2012 Link to this post

    Hi Thierry,

    I have tried to reproduce the exception with the provided code, but without much success. Could you please open a support ticket and attach a sample runnable project demonstrating the issue there?
    Thanks in advance

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Thierry
    Thierry avatar
    22 posts
    Member since:
    Mar 2012

    Posted 05 Dec 2012 Link to this post

    Hi Yana,

    thank you for your answer.

    to be perfectly honest, I am not able to reproduce the issue myself either... It only happens on the machines of two of our clients, and I have absolutely no idea why it happens on their machines and not the others. SO I do not have a running project to reproduce this with 100% certainty.

    Here is what I know :
    - the exception only occurs on 3 machines overall (2 different clients) for now
    - they both have the latest version of the .net framework and the 2012Q2 version of Telerik
    - even when updating to the latest Telerik dlls and the .net 4.5 the issue stays. It basically does not depend on the version of Telerik and .net (tried 6 different combinations, none of them worked)
    - if I put a try/catch around the switch, I don't get the exception any more, but only have the DayViewDefinition in the calendar instead of all 4 of the "normal" views (one of each in the switch), which is not suitable, though it allows them to work on the rest of the software for now.
    - they both have win 7 installed, one 32bit and the other 64bit so it does not seem to be related to that.

    I have a related question though :

    as the issue seems to lie in the RadScheduleView.OnViewDefinitionsCollectionChanged event handler, is there any way I can prevent this handler to be called when I'm adding the viewDefinitions? Since the viewDefinitions are added priori to any display of the calendar, I could do with a "silent" update of the collection, and notify the change only when all viewDefinitions are added.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 10 Dec 2012 Link to this post

    Hello Thierry,

    I am afraid that there is no way to prevent this event from firing when adding ViewDefinitions.

    We're no aware of such an exception and we cannot tell what is the reason for it.  It would be really helpful if you could reproduce it locally and send us more details on the issue.

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top