RtfDataProvider Exception

2 posts, 0 answers
  1. Jaghathish
    Jaghathish avatar
    1 posts
    Member since:
    Jul 2011

    Posted 04 May 2016 Link to this post


    I have a custom control that hosts a RichTextBox/RtfDataProvider in WPF 4.5.

    I'm using Telerik version 2015.3.1104.45.

    Following is the XAML which works fine in the visual studio designer.


    <telerik:RtfDataProvider x:Name="RtfProvider"             Grid.Row="1" 
                Rtf="{Binding RtfFileContent, ElementName=RtfEditorUC, Mode=TwoWay}" 
                RichTextBox="{Binding ElementName=radRTB}" />         <telerik:RadRichTextBox x:Name="radRTB" 
                                    LayoutMode="Paged" VerticalAlignment="Top" 
                                    IsReadOnly="{Binding IsRtfReadOnly, ElementName=RtfEditorUC, Mode=TwoWay}"/>


    However, at runtime, I have the following crash :


    System.Reflection.TargetInvocationException: Une exception a été levée par la cible d'un appel. ---> System.Windows.Markup.XamlParseException: L'invocation du constructeur sur le type 'Telerik.Windows.Documents.FormatProviders.Rtf.RtfDataProvider' qui correspond aux contraintes de liaison spécifiées a levé une exception. ---> System.ArgumentNullException: La valeur ne peut pas être null.
    Nom du paramètre : formatProvider
       à Telerik.Windows.Documents.FormatProviders.DataProviderBase..ctor(ITextBasedDocumentFormatProvider formatProvider, DependencyProperty stringProperty)
       à Telerik.Windows.Documents.FormatProviders.Rtf.RtfDataProvider..ctor()
       à System.Xaml.Schema.XamlTypeInvoker.DefaultCtorXamlActivator.InvokeDelegate(Action`1 action, Object argument)
       à System.Xaml.Schema.XamlTypeInvoker.DefaultCtorXamlActivator.CallCtorDelegate(XamlTypeInvoker type)
       à System.Xaml.Schema.XamlTypeInvoker.CreateInstance(Object[] arguments)
       à MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstanceWithCtor(XamlType xamlType, Object[] args)
       à MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)

    The same code was working fine in WPF 3.5 with Telerik  2012.2.912.35.

    Any help appreciated.

  2. Tanya
    Tanya avatar
    583 posts

    Posted 05 May 2016 Link to this post

    Hi Jaghathish,

    The format providers in RadRichTextBox are loaded using MEF. The data providers rely on the format providers and in case they are not loaded and registered correctly by the MEF, a NullReferenceException is thrown.

    There are several ways to handle this. The first I could suggest you is to change the TypeCatalog with the types you are planning to use in the application. The full list of types used in RadRichTextBox could be found in our documentation

    Alternatively, you could register the format provider with the DocumentFormatProvidersManager like this:
    DocumentFormatProvidersManager.RegisterFormatProvider(new RtfFormatProvider());

    Hope this helps.

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top