RtfDataProvider Exception

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

    Posted 04 May Link to this post

    Hello,

    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" 
                                    Grid.Row="1" 
                                    DocumentInheritsDefaultStyleSettings="True" 
                                    IsSpellCheckingEnabled="False"                                  
                                    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
    Admin
    Tanya avatar
    404 posts

    Posted 05 May 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.

    Regards,
    Tanya
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top