WPF Binding Error running under Citrix

WPF Binding Error running under Citrix

Old forum URL: forums.lhotka.net/forums/t/11245.aspx


richardb posted on Wednesday, March 21, 2012

OK I'm 99.99% sure this is NOT a Csla problem of any making, and my WPF binding code works under WIndows XP and Windows 7 fine, but our IT department has rolled out Citrix now and on one form (out of many) I'm getting this error somewhere in the Xaml binding.

While I'm trying to get access to a UAT Citrix environment with permissions to do things, or get VS 2010 installed on the Citrix farm so I can debug, has anyone else got any ideas?  I ask here as this is a good forum for help.  I will post into the Citrix and WPF forums too.

Yes this is a bit old skool using CslaDataSource and it's Csla 3.8.x.
MVVM next time I promise :-)

Thanks.

 

The code that catches the error.

 ''' <summary>
    ''' Handles data errors on forms when binding.
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Protected Overridable Sub DataChanged(ByVal sender As ObjectByVal e As EventArgs)
 
        Dim dp As Csla.Wpf.CslaDataProvider = TryCast(sender, Csla.Wpf.CslaDataProvider)
        If Not dp.Error Is Nothing Then
            MyGlobals.ErrorHandler(dp.Error, "Data error")
        Else
            RaiseEvent DataChangedInControl(MeEventArgs.Empty)
        End If
 
    End Sub

 

The Error:

Message: Object of type 'System.Int32' cannot be converted to type 'POSTracker.Library.SMRDevelopmentRecord'.
    Source: mscorlib  Stack Trace:  
    at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture,
        BindingFlags invokeAttr)    
    at System.Reflection.MethodBase.CheckArguments(Object[] parameters,
        Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)   
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,
         Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)    
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder,
          Object[] parameters, CultureInfo culture)    
    at Csla.Wpf.CslaDataProvider.DoQuery(Object state) 

 

Some of the Xaml.

 

<local:EditControl x:Class="SMRDevelopmentEdit"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:POSTracker.Wpf"  
    xmlns:csla="clr-namespace:Csla.Wpf;assembly=Csla"  
    xmlns:POSTracker="clr-namespace:POSTracker.Library;assembly=POSTracker.Library"  
    xmlns:system="clr-namespace:System;assembly=mscorlib"
    xmlns:igEditors="http://infragistics.com/Editors"
    xmlns:igDP="http://infragistics.com/DataPresenter"
    xmlns:igWindows="http://infragistics.com/Windows"
    Title="Support Material Record Edit"
                   
    x:Name="LSDevelopmentEdit"
   >
 
    <local:EditControl.Resources>
        <local:VisibilityConverter x:Key="VisibilityConverter" />
        <local:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
 
        <local:BooleanNullToFalseTrueConverter x:Key="BooleanNullToFalseTrueConverter" />
        <csla:IdentityConverter x:Key="IdentityConverter" />
 
        
        <csla:CslaDataProvider x:Key="LSSupportMaterialTypeList"
                           ObjectType="{x:Type POSTracker:SMRSupportMaterialTypeList}"
                           FactoryMethod="GetList"
                           IsAsynchronous="True" />
 
 
        <csla:CslaDataProvider x:Key="PrintTypeList"
                           ObjectType="{x:Type POSTracker:PrintTypeList}"
                           FactoryMethod="GetList"
                           IsAsynchronous="True" />
 
 
        <csla:CslaDataProvider x:Key="LSTypeList"
                           ObjectType="{x:Type POSTracker:SMRSubTypeList}"
                           FactoryMethod="GetList"
                           IsAsynchronous="True" />
        
        <csla:CslaDataProvider x:Key="LSSubTypeList"
                           ObjectType="{x:Type POSTracker:SMRSubCategoryList}"
                           FactoryMethod="GetList"
                           IsAsynchronous="True" />
 
        <csla:CslaDataProvider x:Key="LSEditorList"
                           ObjectType="{x:Type POSTracker:SMRAuthorList}"
                           FactoryMethod="GetEditorList"
                           IsAsynchronous="True" />
        
        <csla:CslaDataProvider x:Key="LSWriterList"
                           ObjectType="{x:Type POSTracker:SMRAuthorList}"
                           FactoryMethod="GetWriterList"
                           IsAsynchronous="True" />
        
        <csla:CslaDataProvider x:Key="LSDevelopmentStatusList"
                           ObjectType="{x:Type POSTracker:SMRDevelopmentStatusList}"
                           FactoryMethod="GetList"
                           IsAsynchronous="True" />
 
        <csla:CslaDataProvider x:Key="SMRDevelopmentRecord"
                           ObjectType="{x:Type POSTracker:SMRDevelopmentRecord}"
                           FactoryMethod="GetLSDevelopmentRecord"
                           IsAsynchronous="False"
                           IsInitialLoadEnabled="False"
                           DataChanged="DataChanged"
                           ManageObjectLifetime="True">
        </csla:CslaDataProvider>
        
        
        
 
        <csla:ObjectStatus x:Key="LSDevelopmentRecordStatus"
                       DataContext="{StaticResource SMRDevelopmentRecord}" />
 
        <ObjectDataProvider x:Key="SuiteTreeviewerSelection"
              ObjectType="{x:Type  local:DataFactory}"  
              IsInitialLoadEnabled="False"
              MethodName="GetData"   >
        </ObjectDataProvider>
 
 
 
        <DataTemplate x:Key="Topic2"  >
            <StackPanel  Orientation="Horizontal">
                <CheckBox IsChecked="{Binding Path=CheckBox}"></CheckBox>
                <TextBlock     Text="{Binding Path=Title}"></TextBlock>
            </StackPanel>
        </DataTemplate>
 
 
    </local:EditControl.Resources>
 
    <Grid Name="MainGrid" Width="Auto" DataContext="{Binding Source={StaticResource SMRDevelopmentRecord}}">

etc.

 

 

RockfordLhotka replied on Wednesday, March 21, 2012

That is the worst kind of thing to debug - where it works in one case and not another, and you have no debugging tools available.

Probably all you can do is take out all the bindings and then re-add them one at a time until you find the one that causes the error. Tedious, but it should work.

richardb replied on Thursday, March 22, 2012

Thanks - yes its painful.

I'm suspecting some broken bindings which I'd noticed in the Output window of VS2010 when running the app, so I'll clean those up first.  Some PropertyStatus control bindings are looking for controls that no longer exist in the Xaml and should have been removed.

I'll confirm if this was the problem later.

 

System.Windows.Data Error: 39 : BindingExpression path error: 'SuiteDataItem' property not found on 'object' ''SuiteDataItem' (HashCode=16899325)'. BindingExpression:Path=SuiteDataItem; DataItem='SuiteDataItem' (HashCode=16899325); target element is 'TreeViewItem' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')
System.Windows.Data Error: 39 : BindingExpression path error: 'SelectedValue' property not found on 'object' ''SMRDevelopmentRecord' (HashCode=55164075)'. BindingExpression:Path=SelectedValue; DataItem='SMRDevelopmentRecord' (HashCode=55164075); target element is 'PropertyStatus' (Name=''); target property is 'Property' (type 'Object')
System.Windows.Data Error: 39 : BindingExpression path error: 'SelectedValue' property not found on 'object' ''SMRDevelopmentRecord' (HashCode=55164075)'. BindingExpression:Path=SelectedValue; DataItem='SMRDevelopmentRecord' (HashCode=55164075); target element is 'PropertyStatus' (Name=''); target property is 'Property' (type 'Object')
System.Windows.Data Error: 39 : BindingExpression path error: 'SelectedValue' property not found on 'object' ''SMRDevelopmentRecord' (HashCode=55164075)'. BindingExpression:Path=SelectedValue; DataItem='SMRDevelopmentRecord' (HashCode=55164075); target element is 'PropertyStatus' (Name=''); target property is 'Property' (type 'Object')
A first chance exception of type 'System.NullReferenceException' occurred in POSTracker.Library.dll
A first chance exception of type 'System.NullReferenceException' occurred in POSTracker.Library.dll
System.Windows.Data Error: 39 : BindingExpression path error: 'SelectedValue' property not found on 'object' ''SMRDevelopmentRecord' (HashCode=55164075)'. BindingExpression:Path=SelectedValue; DataItem='SMRDevelopmentRecord' (HashCode=55164075); target element is 'PropertyStatus' (Name=''); target property is 'Property' (type 'Object')
System.Windows.Data Error: 39 : BindingExpression path error: 'SelectItems' property not found on 'object' ''SMRDevelopmentRecord' (HashCode=55164075)'. BindingExpression:Path=SelectItems; DataItem='SMRDevelopmentRecord' (HashCode=55164075); target element is 'PropertyStatus' (Name=''); target property is 'Property' (type 'Object')
System.Windows.Data Error: 39 : BindingExpression path error: 'txtVersion' property not found on 'object' ''SMRDevelopmentRecord' (HashCode=55164075)'. BindingExpression:Path=txtVersion; DataItem='SMRDevelopmentRecord' (HashCode=55164075); target element is 'PropertyStatus' (Name=''); target property is 'Property' (type 'Object')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=cboWriter'. BindingExpression:(no path); DataItem=null; target element is 'PropertyStatus' (Name=''); target property is 'TargetControl' (type 'DependencyObject')

Copyright (c) Marimer LLC