This is a migrated thread and some comments may be shown as answers.

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

2 Answers 95 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
глеб
Top achievements
Rank 1
глеб asked on 04 Aug 2016, 09:30 AM

Hello Telerik team!

 

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

System.NullReferenceException was unhandled
  HResult=-2147467261
  Message=Ссылка на объект не указывает на экземпляр объекта.
  Source=Telerik.Windows.Controls.FixedDocumentViewers
  StackTrace:
       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...
  InnerException:

Steps before the exception:

<code>

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

 

...

 

pdfViewer.FixedDocumentPresenter =
            pdfViewer.GetRegisteredPresenter(FixedDocumentPresenterNames.FixedDocumentSinglePageViewPresenter);

</code>

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 Answers, 1 is accepted

Sort by
0
глеб
Top achievements
Rank 1
answered on 08 Aug 2016, 12:02 PM

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.

0
Deyan
Telerik team
answered on 09 Aug 2016, 08:23 AM
Hello,

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:
//NavigationService.GetNavigationService(this).Navigate(pb);

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.

Regards,
Deyan
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
PDFViewer
Asked by
глеб
Top achievements
Rank 1
Answers by
глеб
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or