Home Forums WPF controls Xceed Toolkit Plus for WPF ResourceDictionary relative path issue with .NET 4.6

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Odi [Xceed]
    Spectator
    Post count: 426
    #41767 |

    Description

     

    A project that targets .NET Framework 4.6 and that is compiled with Visual Studio 2015 may crash when it references Xceed Extended WPF Toolkit or Xceed DataGrid for WPF. The exception thrown may contain a message that looks like “Initialization of ‘AssemblyName’ threw an exception.”

     

    The issue arises because these products use an URI format for ResourceDictionary that’s no longer recognized by the parser in .NET Framework 4.6. This is fixed in Xceed Extended WPF Toolkit v2.5 Community Edition on Nuget and Codeplex and Plus Edition v2.7 on NuGet and Xceed.com. For Xceed DataGrid for WPF, the issue only occurs in an uncommon use case (described below) and will be fixed in Xceed DataGrid for WPF v5.7 when that is released later this year.

     

    Manual fixes are described below to avoid the issue in current and previous versions of the products.

     

    Manual fix for Xceed Extended WPF Toolkit

     

    A new binary version of the assemblies must be compiled from the source code.  The lines of code to change are located in:

     

    File: Xceed.Wpf.Toolkit/Core/VersionResourceDictionary.cs

    Method: ISupportInitialize.EndInit()

     

    Lines to change:

     

    string uriStr = string.Format( @”{0};v{1};component/{2}”, this.AssemblyName, _XceedVersionInfo.Version, this.SourcePath );

    this.Source = new Uri( uriStr, UriKind.Relative );

     

    Lines to use instead:

     

    string uriStr = string.Format( @”pack://application:,,,/{0};v{1};component/{2}”, this.AssemblyName, _XceedVersionInfo.Version, this.SourcePath );

    this.Source = new Uri( uriStr, UriKind.Absolute );

     

    Manual fix for Xceed DataGrid for WPF

     

    The ill-formatted URI can only be found in a custom generated theme from the Xceed DataGrid for WPF Theme Wizard.  The XAML lines to change are located in:

     

    File: CustomThemeProject/themes/generic.xaml

     

    Replace all ResourceDictionary URI that look like this:

     

    <ResourceDictionary Source=”CustomThemeName;;;component\themes/CustomThemeName/…” />

     

    By this:

     

    <ResourceDictionary Source=”/CustomThemeName;;;component\themes/CustomThemeName/…” />

     

    The difference between these two is the ‘/’ at the beginning of the path.

    Imported from legacy forums. Posted by Odi [Xceed] (had 805 views)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.