Silverlight crash opening Context menu

8 posts, 0 answers
  1. VH
    VH avatar
    4 posts
    Member since:
    Apr 2008

    Posted 09 Mar 2012 Link to this post

    Hi,
    We have a problem with a context menu, which is created and filled exclusively in code. Sometimes, the whole application crashes when the context menu is about to be displayed. Often the error can't be tracked as the application crashes completely. However sometimes we can track an error message which I think is related to the issue:

       bei MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)

       bei MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)

       bei MS.Internal.XcpImports.FrameworkElement_ApplyTemplate(FrameworkElement frameworkElement)

       bei System.Windows.Controls.Control.ApplyTemplate()

       bei Telerik.Windows.Controls.RadMenuItem.ChangeTemplate(MenuItemRole role)

       bei Telerik.Windows.Controls.RadMenuItem.UpdateRole()

       bei Telerik.Windows.Controls.RadMenuItem.OnLoaded(Object sender, RoutedEventArgs e)

       bei MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)

       bei MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

      

       Failed to assign to property  'System.Windows.Controls.ContentPresenter.Content'. [Line: 476 Position: 83]

     

    I believe that it hast to do with initializing the context menu because once the menu has been opened the error will not appear anymore.  But most of the time it workes so it is hard to reproduce the error (It always works when I step thorough the code in debug mode). 
    Could you give us any hints what could be the matter?
    Thanks a lot
    Volkmar

     

  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 14 Mar 2012 Link to this post

    Hi Martin,

    We are not aware of such an error and we are not able to reproduce the bad behavior. Could you please send us a sample code or project where the error can be reproduced. Also could you please tell us if you are using SL4 or SL5 binaries.

    Regards,
    Boyan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Jamest
    Jamest avatar
    41 posts
    Member since:
    Apr 2007

    Posted 29 Mar 2012 Link to this post

    I am experiencing the same thing with Silverlight 4 binaries (can't try 5) in both the 2012 Q1 and sp1 binaries. Were you able to figure out a work around? I have a RadMenu and Context menus that build contextually depending on the item selected. They are built in code behind in a large switch case (gasp). They load properly for first item use, as soon as it goes to open again  after I clear the items and load them again the app crashes . Another thing is that my items aren't bound and this scenario has been working since silverlight 3 releases. Same result with black(default), windows 7, and silver themes.

    Line: 453
    Error: Sys.InvalidOperationException: Invalid XAML for control 'MMSMSL'. [] (line 512, col 65): Failed to assign to property 'System.Windows.Controls.ContentPresenter.Content'.
  5. VH
    VH avatar
    4 posts
    Member since:
    Apr 2008

    Posted 30 Mar 2012 Link to this post

    Yes there is a workaround.
    Create your RadMenu object with a dummy-item (inclusive all submenus).
    After that add the RadMenuItems you need and remove the dummy finally.
    It works for me. Hope this helps!
  6. Jamest
    Jamest avatar
    41 posts
    Member since:
    Apr 2007

    Posted 30 Mar 2012 Link to this post

    MH -Thank you for your feedback. I tried that and it worked with limited success. The error is no longer thrown right away, but still occurs with normal usage. I have nested context menus, and a radmenu item dynamically populated on selection of an item. So sometimes it is opened and other times its not.  I have submitted a support ticket as all of this has been working up until this last release. I had done a work around awhile back to get around the having to add a dummy child by setting the main menuitem's header to null, clearing its sub-items, and then reassigning the header. I appreciate your time and have a great weekend.

       Thanks, Jordan
  7. Stefan Falz
    Stefan Falz  avatar
    3 posts
    Member since:
    Apr 2009

    Posted 30 Mar 2012 Link to this post

    Hi Boyan,

    please take a look at the following thread. I think the reason for this error is the same or at least a similar one as described in the othert thread.

      http://www.telerik.com/community/forums/silverlight/richtextbox/problem-with-image-inside-richtextbox.aspx

    IMHO the problem has nothing to do with user defined context menus because the integrated context menus in RadRichTextBox (at least the image context menus) are throwing the same exception.
  8. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 02 Apr 2012 Link to this post

    Hi Guys,

    We reproduced the problem, thanks to Ender and after some investigation we found that there is a bug in Silverlight 4 when control templates are changed and there are visual elements in the Header. The bug is fixed in SL5 and that is why it is working as expected there.

    If you don't want to upgrade to Silverlight 5, we found a workaround that will work in Silverlight 4 as well. You can use DataItems instead of RadMenuItems and it will work as expected.

    You can find attached  the sample project that Ender send us with the workaround applied.

    Kind regards,
    Boyan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  9. Jamest
    Jamest avatar
    41 posts
    Member since:
    Apr 2007

    Posted 02 Apr 2012 Link to this post

    I appreciate the work around. But it would just cost too much time to do that in 12 projects. I was able to convince my team to give 5 a shot and it appears to be working. Hopefully 1000+ users don't find it too much of a hassle upgrading their client versions. Thank you,
               Jordan
Back to Top
DevCraft banner