Object reference not set

Aug 12, 2010 at 2:01 PM
Hi There, I downloaded and compiled the source, When selecting my xps file I get an "Object reference not set to an instance of an object" Any ideas what is going wrong? Or is this a bug? Thanks, Dave.
Nov 9, 2010 at 4:01 PM

I got the same error when trying to open a local file.  The exception is raised in the ReadPackageContent method in the MainPage.xaml.cs.  It seems that each call to Application.GetResourceStream is returning null, so the call to

Application.GetResourceStream(_streamResourceInfo, ConvertPartName(FixedDocSeqPath)).Stream

  is causing the NullReferenceException.  I haven't been able to find a way to resolve the issue.  Maybe someone with a little better understanding of the XPS architecture can provide some insight.

Also, when trying to load a remote file from the web via URL, I get a security exception.  So in short, this code doesn't work at all for me.

Dec 8, 2011 at 6:28 PM

I have discovered that happens when you try to open an xps file created using the xps printer. If you open a xps file created by using "Save As" and selecting the xps format it is viewable. It appears the xml under the hood is different.

Jan 24, 2012 at 6:17 PM
Edited Jan 24, 2012 at 7:01 PM

(Sorry for my bad english)
The problem is not in the XML but in the XPS file. If you rename the XPS file to ZIP, discompact it and recompact to ZIP (i tested using winRar) and rename it again to XPS, almost works... but now it choke when trying to parse the XAML with a "Cannot find a Resource with the Name/Key R0"  because in the XAML it created multiple:
Data="{StaticResource RX}"
 where X is a number. I tried to simply remove those "Data" from the XAML and it loaded but some random letters are missing from the render (!?).... I think it would be nice to be able to load any XPS, not only those generated by Office but sadly I do not have the sufficient skills to make this work (i am trying to hack something, anyway)

 

PS.: Looks like the StaticResource error only happens with PDF files... Images and text files are working fine after re-compact the xps file.

 

leo