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

[Solved] CrossAppDomainMarshaledException?

13 Answers 171 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tim
Top achievements
Rank 1
Tim asked on 23 Oct 2009, 12:32 PM
I am seeing an odd exception which closes my browser window.

System.CrossAppDomainMarshaledException was unhandled 
Message: System.NullReferenceException: Object reference not set to an instance of an object
   at AutoVirt.Ui.Client.App.Application_UnhandledException(Object sender, ApplicationUnhandledExceptionEventArgs e) 
   at MS.Internal.Error.CallApplicationUEHandler(Exception e) 
   at MS.Internal.Error.CallAUEHandler(UInt32 hr, UInt32& bIsHandled) 

I took an example from your demos here: http://demos.telerik.com/silverlight/#GridView/RowDetails and came up with the following:

<Grid.Resources> 
  <Resources:PublicStringResources x:Key="i18n"/> 
    <DataTemplate x:Key="RowDetailsTemplate"
      <Grid Background="White"
        <Grid.RowDefinitions> 
          <RowDefinition Height="Auto"/> 
        </Grid.RowDefinitions> 
        <TextBlock Margin="3,7,3,7" TextWrapping="Wrap" Text="{Binding Message}"/> 
      </Grid> 
    </DataTemplate> 
  </Grid.Resources> 
... 
  <TelerikGridView:RadGridView Margin="3" Grid.Row="2" Grid.Column="0" 
    ItemsSource="{Binding Path=Data, Mode=OneWay}" 
    RowDetailsTemplate="{StaticResource RowDetailsTemplate}" 
    RowDetailsVisibilityMode="VisibleWhenSelected" 
    AutoGenerateColumns="False"
... 
 
 

If I change the 4th line from

      <Grid Background="White">
to
      <Grid Background="White" Width="*">

(or make other changes - this is the simplest case to make it fail)  I get the exception above and the app and browser both exit.

Tim







13 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 23 Oct 2009, 01:01 PM
Hello Tim,

For the element in the row details template (Grid in your case) you should either specify a fixed width or leave it without any width.

What other changes cause this exception to occur. Could please send us the project that reproduces this exception, since we would like to debug it. Thanks in advance.

Regards,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tim
Top achievements
Rank 1
answered on 23 Oct 2009, 01:16 PM
I am generally opposed to fixed widths.  I wanted the textblock to wrap, but it won't if it has no width because it is inside a RadGridView with horizontal scrolling which allows it to be infinitely wide, thus it will not wrap.  I want wrapping, no scrollbar, width-of-my-container semantics.

The other change I had made was I tried to use an IValueConverter inside the DataTemplate - which caused exactly the same error.

Tim

0
Rossen Hristov
Telerik team
answered on 23 Oct 2009, 01:18 PM
Hi Tim,

Would it be possible to send us your test project. Thanks in advance.

Best wishes,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tim
Top achievements
Rank 1
answered on 23 Oct 2009, 02:01 PM
<UserControl x:Class="SilverlightApplication6.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"  
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    <Grid x:Name="LayoutRoot"
        <Grid.Resources> 
            <DataTemplate x:Key="RowDetailsTemplate"
                <!-- Adding the Width="*" causes the app to die --> 
                <Grid Margin="5,0,0,0" Width="*"
                    <Grid.RowDefinitions> 
                        <RowDefinition Height="Auto"/> 
                    </Grid.RowDefinitions> 
                    <TextBlock Margin="3,7,3,7" TextWrapping="Wrap" Text="{Binding Message}"/> 
                </Grid> 
            </DataTemplate> 
        </Grid.Resources> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="*"/> 
        </Grid.RowDefinitions> 
        <Controls:RadGridView x:Name="Grid" Margin="3" Grid.Row="2" Grid.Column="0" 
            ScrollMode="RealTime" 
            ItemsSource="{Binding Path=Data, Mode=OneWay}" 
            RowDetailsTemplate="{StaticResource RowDetailsTemplate}" 
            RowDetailsVisibilityMode="VisibleWhenSelected" 
            ColumnsWidthMode="Fill"  AutoGenerateColumns="False"
            <Controls:RadGridView.Columns> 
                <Controls:GridViewDataColumn  
                                HeaderText="Name"  
                                UniqueName="Name" Width=".4*" IsReadOnly="True"/> 
                <Controls:GridViewDataColumn  
                                Header="Rank" 
                                UniqueName="Rank" Width=".4*" IsReadOnly="True"/> 
                <Controls:GridViewDataColumn 
                                HeaderText="Status" UniqueName="Status" 
                                Width=".2*" IsReadOnly="True"/> 
            </Controls:RadGridView.Columns> 
        </Controls:RadGridView> 
    </Grid> 
</UserControl> 
 

using System; 
using System.Collections.Generic; 
using System.Collections.ObjectModel; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Animation; 
using System.Windows.Shapes; 
 
namespace SilverlightApplication6 
    public partial class MainPage : UserControl 
    { 
        public ObservableCollection<RecordData> Data { getprivate set; } 
        public MainPage() 
        { 
            Data = new ObservableCollection<RecordData>(); 
            InitializeComponent(); 
            LayoutRoot.DataContext = this
            for (int i = 0; i < 100; i++) 
                Data.Add(new RecordData 
                             { 
                                 Name = "Tim"
                                 Rank = "Developer"
                                 Message = "All work and no play makes Tim a dull boy"
                                 Status = StatusEnum.maybe 
                             }); 
        } 
    } 
     
    public enum StatusEnum 
    { 
        yes, no, maybe 
    } 
 
    public class RecordData 
    { 
        public string Name { getset; } 
        public string Rank { getset; } 
        public string Message { getset; } 
        public StatusEnum Status { getset; } 
    } 
 
0
Rossen Hristov
Telerik team
answered on 23 Oct 2009, 02:41 PM
Hi Tim,

Now I saw the error. Grid.Width is of type double and you cannot assign "*" to it. You could set it to "Auto", but there is no point, since this is the default value. Simply do not set its Width at all.

Currently, the grid rows are measured with Infinity in order to be able to calculate the horizontal scroll-bar correctly and that is why you will not be able to achieve the width-of-my-container semantics with the current version.

With the Q3 Release we will introduce a property of GridViewDataControl called HorizontalScrollBarVisibility. When it is set to Disabled, the grid rows will be measured with whatever width the grid has. Then you should be able to get the TextBlock wrapping since the width will be a fixed number and not Infinity.

Please, let me know if you have any other questions.

Best wishes,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tim
Top achievements
Rank 1
answered on 23 Oct 2009, 02:46 PM
Thanks, Ross.  Q3 will be... November some time?

What I *really* want is a simple row with "colspan" semantics that looks exactly like the row above it, that I can write a multi-line, text-wrapped, detailed explanation of the Status column.

Name       | Rank         | Status
Tim          | Developer | Anxious
Tim is anxious for the Q3 release


Tim


0
Rossen Hristov
Telerik team
answered on 23 Oct 2009, 02:53 PM
Hello Tim,

You are correct, the Q3 Release is scheduled for early November.

Until then you should set an fixed width to the root element inside the RowDetailsTemplate in order to achieve text-wrapping.

Regards,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tim
Top achievements
Rank 1
answered on 23 Oct 2009, 03:45 PM
OK, suppose I wanted to put a status icon and a message in that row.  I would do this in a cell using a ControlTemplate, as documented here in many different threads.  ControlTemplate is an invalid type for the RowDetailsTemplate property.  Is there any way to make this work (using an IValueConverter)??  For the sake of discussion above, assume that the StatusEnum.maybe ought to display a ? icon, and yes a green check, and no a red X... I know how to do this with IValueConverter in a ControlTemplate...

Thanks,
Tim


0
Rossen Hristov
Telerik team
answered on 26 Oct 2009, 11:14 AM
Hello Tim,

The RowDetailsTemplate is of type DataTemplate as described in the help topic about Row Details.

You can place any control inside this DataTemplate and its DataContext will be the same as the DataContext of its parent row. This is actually the data item associated with the row. Having this in mind, you can bind to any of the data item properties inside your control.

Here is a small example:

<UserControl x:Class="TicketID_252741_RowDetailsWithIcon.MainPage"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:local="clr-namespace:TicketID_252741_RowDetailsWithIcon"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
    <Grid>
      <Grid.Resources>
        <local:PositionToBrushConverter x:Key="PositionToBrushConverter"/>
        <DataTemplate x:Key="PlayerRowDetailsTemplate">
          <!-- Take a look at the bindings. They are bound to the same properties that the columns are bound to.-->
          <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Name}"/>
            <TextBlock Text=" is with number "/>
            <TextBlock Text="{Binding Number}"/>
            <TextBlock Text=". He plays as a "/>
            <!-- This is how you can translate your enum to a color and use it to color anything that you like.-->
            <TextBlock Text="{Binding Position}"
                       Foreground="{Binding Position, Converter={StaticResource PositionToBrushConverter}}"/>
            <TextBlock Text=" for "/>
            <TextBlock Text="{Binding Country}"/>
            <TextBlock Text="."/>
          </StackPanel>
        </DataTemplate>
      </Grid.Resources>
        <telerik:RadGridView Name="playersGrid"
                             AutoGenerateColumns="False"
                             RowDetailsTemplate="{StaticResource PlayerRowDetailsTemplate}"
                             RowDetailsVisibilityMode="Visible">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Name"
                                            DataMemberBinding="{Binding Name}">
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn Header="Number"
                                            DataMemberBinding="{Binding Number}">
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn Header="Position"
                                            DataMemberBinding="{Binding Position}">
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn Header="Country"
                                            DataMemberBinding="{Binding Country}">
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</UserControl>

using System;
using System.Globalization;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
 
namespace TicketID_252741_RowDetailsWithIcon
{
    public class PositionToBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            switch((Position)value)
            {
                case Position.GK:
                    return new SolidColorBrush(Colors.Yellow);
                case Position.DF:
                    return new SolidColorBrush(Colors.Cyan);
                case Position.MF:
                    return new SolidColorBrush(Colors.Orange);
                case Position.FW:
                    return new SolidColorBrush(Colors.Red);
                default:
                    return new SolidColorBrush(Colors.Black);
            }
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

I have attached the sample project. You can create any icon in the row details and bind its color to the enum by using a converter similar to mine.

To learn more about row details you can check our this example and my blog post.

I hope this helps.

Sincerely yours,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tim
Top achievements
Rank 1
answered on 26 Oct 2009, 12:12 PM
As soon as I combine the DataTemplate and the Converter I get the exception I mentioned in .0.  I will spend some time today trying your example in an attempt to figure out where they differ.

Thanks,
Tim

0
Tim
Top achievements
Rank 1
answered on 13 Jan 2010, 09:36 PM
Is the HorizontalScrollBarVisibility property available yet?  I have Q3 now and it appears not to be on RadGridView.  It is really hard to design an application which flows to the window size without the Width=* or the ability to disable that horizontal scrollbar.

Any news on the Q3 SP targeted for mid-Jan?  I have a handful of support tix waiting for this.  I don't see a dev build newer than Q3_2009_1219.

Thanks,
Tim

0
Accepted
Vlad
Telerik team
answered on 14 Jan 2010, 07:08 AM
Hello Tim,

Indeed HorizontalScrollBarVisibility is available and our Q3 SP2 will be uploaded officially later today.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tim
Top achievements
Rank 1
answered on 15 Jan 2010, 10:19 PM
This works now hiding the horizontal scroll bar, thanks!

Tim

Tags
GridView
Asked by
Tim
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Tim
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or