UnsupportedFileFormatException when opening .xps files

I am using version 10.6.0.0 of the Aspose.Words library on Windows 7.

When I attempt to load any xps file:

Document document = new Document(@"c:\Sample.xps");

I receive the exception:

Aspose.Words.UnsupportedFileFormatException was unhandled
HResult=-2146233088
Message=Unknown file format.
Source=Aspose.Words
StackTrace:
at Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46)
at Aspose.Words.Document.x5d95f5f98c940295(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46)
at Aspose.Words.Document…ctor(String fileName, LoadOptions loadOptions)
at Aspose.Words.Document…ctor(String fileName)
at WindowsFormsApplication3.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\rich.quackenbush\Documents\Visual Studio 2010\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs:line 22
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApplication3.Program.Main() in c:\users\rich.quackenbush\documents\visual studio 2010\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: 

The same version of Aspose.Word appears to work in our production environment. Is there an additional piece of configuration I need?

Hi Rich,

Thanks for your query. Aspose.Words mimics the same behavior as MS Word do. You can not load XPS in Aspose.Words.Document. Please read LoadFormat and SaveFormat Enumeration form following documentation links.
https://reference.aspose.com/words/net/aspose.words/loadformat/
https://reference.aspose.com/words/net/aspose.words/saveformat/

Please let us know if you have any more queries.

Hi Rich,

Thanks for your inquiry.

I am afraid, none of Aspose products provide the functionality of loading/importing XPS files as due to the internal format of .XPS document. You can think of .XPS file as being ‘flattened’ in a sense, all of the text, lines and pictures are stored in a pure uneditable format making it near impossible to convert the elements (texts and paragraphs etc) back into an editable form e.g. Word format. I would suggest you please read the Aspose.Words documentation here:
https://docs.aspose.com/words/net/

If we can help you with anything else, please feel free to ask.

Best Regards,