This is a migrated thread and some comments may be shown as answers.

System.ArgumentException when adding viewDefinitions to RadScheduleView

5 Answers 114 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Michel
Top achievements
Rank 1
Michel asked on 29 Nov 2012, 04:40 PM
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

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 04 Dec 2012, 12:34 PM
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.

0
Michel
Top achievements
Rank 1
answered on 05 Dec 2012, 10:22 AM
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.
0
Yana
Telerik team
answered on 10 Dec 2012, 10:13 AM
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.

0
Carlos
Top achievements
Rank 1
answered on 31 Mar 2020, 10:13 PM

I'm having this issue right now, any news about it? I think it's related with some windows update.

I'm using 2013Q2 version.

Thanks

0
Martin Ivanov
Telerik team
answered on 03 Apr 2020, 02:53 PM

Hello Carlos,

I would recommend you to update to the latest version of Telerik UI for WPF and see if the issue still reproduces there. If so, you can open a new support ticket and attach a project showing the issue.

Regards,
Martin Ivanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ScheduleView
Asked by
Michel
Top achievements
Rank 1
Answers by
Yana
Telerik team
Michel
Top achievements
Rank 1
Carlos
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or