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

Uncaught Error when Navigating Frame away from Page with HtmlPlaceholder

2 Answers 47 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 15 Dec 2011, 08:49 PM

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 Answers, 1 is accepted

Sort by
0
Greg Reynolds
Top achievements
Rank 1
answered on 16 Dec 2011, 03:18 PM
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()    
0
Greg Reynolds
Top achievements
Rank 1
answered on 16 Dec 2011, 04:00 PM
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);

Tags
HTMLPlaceHolder
Asked by
Andy
Top achievements
Rank 1
Answers by
Greg Reynolds
Top achievements
Rank 1
Share this question
or