Void UpdateContentPresenter throws a NRE after an attempt to assign any presenter to it

3 posts, 0 answers
  1. глеб
    глеб avatar
    2 posts
    Member since:
    Aug 2016

    Posted 04 Aug Link to this post

    Hello Telerik team!


    I get the following exception when I try to assign a presenter to RadPdfViewer.FixedDocumentPresenter field:

    System.NullReferenceException was unhandled
      Message=Ссылка на объект не указывает на экземпляр объекта.
           Telerik.Windows.Controls.FixedDocumentViewerBase.UpdateContentPresenter(IFixedDocumentPresenter presenter)
            Telerik.Windows.Controls.FixedDocumentViewerBase.InitializeFixedDocumentPresenter(IFixedDocumentPresenter releasedPresenter, IFixedDocumentPresenter presenter)
            Telerik.Windows.Controls.FixedDocumentViewerBase.set_FixedDocumentPresenter(IFixedDocumentPresenter value)

        ...Internal app methods...

    Steps before the exception:


    pdfStream = new MemoryStream();
    byte[] pdfCashe = File.ReadAllBytes(_pageView.LocalImagePath);
    var ms = new MemoryStream(pdfCashe);
    pdfViewer.DocumentSource = new PdfDocumentSource(ms);




    pdfViewer.FixedDocumentPresenter =


    pdfViewer - RadPdfViewer initialized in XAML

    _pageView.LocalImagePath is a string containing a path to the pdf file


    The "DocumentSource" field of the viewer is not null, a "Document" field inside is null.


    What could be the cause? The creation of a new FixedDocumentSinglePageViewPresenter itself completes successfully.

    I use 2015.3.1104.40 Telerik libraries.


    Thank you in advance!

  2. глеб
    глеб avatar
    2 posts
    Member since:
    Aug 2016

    Posted 08 Aug Link to this post

    UPD: Presenter assigns just fine in default WPF project main window. The exception occurs when you use a page, assigned to the Window.Content field, and init viewer from the page. Occurs in 2016.2.503.40 as well. Example is here: https://drive.google.com/open?id=0B0WAmxqvEQ1GYXI2WDlvQ2ljcG8


    Please advice, is that an intended behaviour and how can it be avoided? Using the viewer from a window is not likely an option.

  3. DevCraft R3 2016 release webinar banner
  4. Deyan
    Deyan avatar
    125 posts

    Posted 09 Aug Link to this post


    Thank you for contacting us and sending us a demo project.

    At first, when we run the project there was a NullReferenceException in MainWindow_Loaded method. That exception had different stack trace and was caused by GetNavigationService method which returns null. However, after commenting out the following code we were able to workaround this exception and reproduce the original exception you have reported:

    When researching the original issue I have noticed that you are using Telerik NoXaml binaries. As UpdateContentPresenter method uses elements that are defined RadPdfViewer template these elements should be available when OnApplyTemplate method of the control is called. Otherwise, the value of these elements is null and NullReferenceException occurs.

    In order to have RadPdfViewer's template applied correctly, you should either use standard Telerik XAML binaries or if you are using NoXaml you should merge the resource dictionaries for the desired theme. More information about Theming and working with XAML and NoXaml binaries may be found in this documentation article.

    I hope this is helpful.

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