Uncaught Error when Navigating Frame away from Page with HtmlPlaceholder

3 posts, 0 answers
  1. Andy
    Andy avatar
    4 posts
    Member since:
    Aug 2011

    Posted 15 Dec 2011 Link to this post

    We are finishing up a 'container' Silverlight application that makes a lot of use of pages with different HtmlPlaceholders being loaded within a common ContentFrame. The application supplies credentials when it can, and determines which users have access to which embedded web/browser-based applications.

    Whenever a user switches the navigation on the ContentFrame (selects a different application button) the Chrome debugger (and others) reports the following error:

    Uncaught Error: Unhandled Error in Silverlight 2 Application Value does not fall within the expected range. at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData) at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData) at MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, UIElement visual) at Telerik.Windows.Controls.ApplicationHelper.TransformToScreenRoot(UIElement target) at Telerik.Windows.Controls.RadHtmlPlaceholder.OnLayoutUpdated() at Telerik.Windows.Controls.RadHtmlPlaceholder.<Init>b__14() 

    The page is really simple:

    <navigation:Page 
            NavigationCacheMode="Disabled"
            x:Class="Portal.Foo" 
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
            xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
            xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><br><span class="Apple-tab-span" style="white-space:pre"> 
            <Grid 
                    x:Name="LayoutRoot"
                   Style="{StaticResource LayoutRootGridStyle}"
                   Margin="0">
                   <telerik:RadHtmlPlaceholder
                           x:Name="HtmlHostCtrl
                           HorizontalAlignment="Stretch"
                           VerticalAlignment="Stretch"
                           Margin="5,5,5,5" />
            </Grid>
    </navigation:Page>


    As is the code:


    using System;
    using System.Windows;
    using System.Windows.Browser;
    using System.Windows.Media;
    using System.Windows.Navigation;


    namespace Portal.Foo
    {
    public partial class Bar
    {
            App a = (App)System.Windows.Application.Current;
            public Bar()  
            {
            InitializeComponent();
            HtmlHostCtrl.SourceUrl = new Uri(a.BarUrl as String);
            }

            protected override void OnNavigatedFrom(NavigationEventArgs e)
            {
            HtmlHostCtrl.Visibility = System.Windows.Visibility.Collapsed;
            }
    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
            HtmlHostCtrl.Visibility = System.Windows.Visibility.Visible;
            }
    }
    }

    Any guidance would be most welcome. The application mostly works despite these errors, but the Silverlight application does lock up (go blank) sometimes with a lot or rapid page navigation, and I think this may be related.

    TIA,
    Andy

  2. Greg Reynolds
    Greg Reynolds avatar
    2 posts
    Member since:
    Jul 2006

    Posted 16 Dec 2011 Link to this post

    I get the same error, when unloading of the control. (which causes a Layout Update which is where it's really happening)

    I also tried the most recent build 1214 and still have the issue.

    To reproduce, add the HTMLPlaceholder to a childwindow, set it to a url, open and close the window a couple times if it doesn't happen the first time.

    Category: ManagedRuntimeError      
    Message: System.ArgumentException: Value does not fall within the expected range.
       at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
       at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
       at MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, UIElement visual)
       at System.Windows.UIElement.TransformToVisual(UIElement visual)
       at Telerik.Windows.Controls.RadHtmlPlaceholder.OnLayoutUpdated()
       at Telerik.Windows.Controls.RadHtmlPlaceholder.<Init>b__14()    
  3. DevCraft banner
  4. Greg Reynolds
    Greg Reynolds avatar
    2 posts
    Member since:
    Jul 2006

    Posted 16 Dec 2011 Link to this post

    I found that if I remove the control from the grid its contained in, before I close, The error is worked around.

    LayoutRoot.Children.Remove(HTMLPlaceHoder);

Back to Top