RadTabItem XamlParseException

6 posts, 0 answers
  1. Bryan Johnson
    Bryan Johnson avatar
    18 posts
    Member since:
    May 2010

    Posted 20 Oct 2010 Link to this post

    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
  2. Patrick
    Patrick avatar
    5 posts
    Member since:
    Aug 2010

    Posted 25 Oct 2010 Link to this post

      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

  3. DevCraft banner
  4. Bryan Johnson
    Bryan Johnson avatar
    18 posts
    Member since:
    May 2010

    Posted 25 Oct 2010 Link to this post

    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!). 
  5. Patrick
    Patrick avatar
    5 posts
    Member since:
    Aug 2010

    Posted 26 Oct 2010 Link to this post

    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. 
  6. Pasha Alasheev
    Pasha Alasheev avatar
    4 posts
    Member since:
    Jan 2010

    Posted 06 Dec 2010 Link to this post

    Is it solved in Q3 2010?

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

  7. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 07 Dec 2010 Link to this post

    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
Back to Top
DevCraft banner