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

RadTabItem XamlParseException

5 Answers 150 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Bryan Johnson
Top achievements
Rank 1
Bryan Johnson asked on 20 Oct 2010, 10:58 PM
I'm getting a XamlParseException error when trying to run my project.  Actually, sometimes the project will run and other times it won't.  When I get the error it stops at InititalizeComponent() in the main page with the following error:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.RadTabItem.OnLeftTemplateChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
   at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty property)
   at MS.Internal.FrameworkCallbacks.InvalidateProperty(IntPtr nativeTarget, UInt32 propertyId) [Line: 0 Position: 0]

I've searched the forums, google, etc. and cannot determine why I'm getting the error and/or why it is intermittent.  Have you encountered this problem before?  It seems to have something to do with the RadTabItem control.  Please help!

Thank you in advance,
Bryan Johnson

5 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 25 Oct 2010, 07:31 AM
    Hi. I am getting the same issue. The same issue occurs using both Q1 2010 and Q2 2010 versions of the Silverlight controls.
    {System.NullReferenceException: Object reference not set to an instance of an object. at
    Telerik.Windows.Controls.RadTabItem.OnLeftTemplateChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
       at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty property)
       at MS.Internal.FrameworkCallbacks.InvalidateProperty(IntPtr nativeTarget, UInt32 propertyId

    It works around 10% of the time. The other 90% it doesn't. It is related to the RadPane.

    I believe this is the same issue as the one described in this related bug: http://www.telerik.com/community/forums/silverlight/dockpanel/exception-on-loading-page-related-to-radpane.aspx because when I debug without breakpoints it fails at InitializeComponent() with:

    Unable to cast object of type 'System.Windows.Controls.ContentControl' to type 'Telerik.Windows.Controls.RadPane'. (which is the error of the related bug) But when I put a breakpoint on the Application_UnhandledException, the ExceptionObject on the ApplicationUnhandledExceptionEventArgs is the NullReferenceException described above.

    I was unable to reproduce this in a simple scenario. It seems to start occurring sporadically when you put more controls into your docking control - and when you add more and more complexity in it happens more and more often.

    Can you please try to reproduce and fix this??? A lot of people are having this issue. If not, can you please show us where to download the Q3 2009 silverlight version of the controls? According to the first post of the related bug thread, it works with Q3 2009.

    Cheers,
    Patrick

0
Bryan Johnson
Top achievements
Rank 1
answered on 25 Oct 2010, 02:34 PM
I've found the problem in my application.  Basically, it's a timing issue where objects are not fully realized in memory and there is an attempt to reference their properties or methods.  In my case, as the application has grown it is taking longer to parse the xaml and build the objects, and I was setting properties, etc. in the .cs files at the beginning of the process, especially in the main page.  So, after considerable research and trial/error I restructured my code so that any reference to an object's property or method takes place in the Loaded event.  So far, this seems to have solved the problem.  It was a difficult problem to debug because the error was very non-specific and in my case was referencing 'Line 0' (that's a big help!). 
0
Patrick
Top achievements
Rank 1
answered on 26 Oct 2010, 07:33 AM
Thanks Bryan - you're right, it is some sort of race condition. I was able to reduce the frequency of the error significantly by making the viewmodel locator pre-load all the view models first before any of the controls are rendered, rather than having the viewmodellocator create the viewmodels on the fly when they are requested by the datacontext attribute of a control.

It still happens once in a blue moon, so there must be something else within my code, but its workable for now. I'll keep you posted if I discover anything new about this. 
0
Pasha Alasheev
Top achievements
Rank 1
answered on 06 Dec 2010, 12:13 PM

Is it solved in Q3 2010?

I'm using Q2 2010 and the issue is reproducible sometimes. I can't reproduce it constantly

0
Miroslav Nedyalkov
Telerik team
answered on 07 Dec 2010, 10:47 AM
Hi Pasha,

 I answer your question the following thread - http://www.telerik.com/community/forums/silverlight/dockpanel/exception-on-loading-page-related-to-radpane.aspx#1446782.

Kind regards,
Miroslav Nedyalkov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
TabControl
Asked by
Bryan Johnson
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Bryan Johnson
Top achievements
Rank 1
Pasha Alasheev
Top achievements
Rank 1
Miroslav Nedyalkov
Telerik team
Share this question
or