We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Document.Print throws exception for DOC file using C#

The attached document (VT01.doc) produces the attached exception (Exception.png) through the code.:

Document document = new Document("VT01.doc");
foreach (Section section in document.Sections) {
section.PageSetup.FirstPageTray = DefaultPageSettings.PaperSource.RawKind;
section.PageSetup.OtherPagesTray = DefaultPageSettings.PaperSource.RawKind;
}
document.Print();

Any printer, XPS/PCL/PS produces the error; For testing purposes this is run with default printer as a Microsoft OneNote print queue.

The code is run outside the main GUI thread.
Operating system is Windows7, dotnet 3.5 (runtime 2.0.50727).
Aspose.Words 11.1 (From Aspose.Total package)

Any comments?

For good measure, I just tested this on a fresh Windows XP SP3 install.

Error is consistent, and 100% re-produce-able.

Hi Jens,

Thanks for your query. I have tested the scenario and have not managed to reproduce the same problem at my end. Please use the latest version of
Aspose.Words for .NET 11.1.0.

The exception is handled internally by Aspose.Words.dll,

Seeing that I have visual studio setup to break on such exceptions, (System.InvalidOperationException), I need you to confirm that the contents of the output is valid, and that this exception will not result in corrupt output being sent to the printer.

I have provided a simple test project, that produces the exception, if needed.

Thank you.

Hi Jens,

Thanks for sharing more information. I have tested the shared code at my end and have not found any problem. I have noticed that you are using Aspose.Words DLL for .net 2.0. Please set Target Framework to .net 2.0 of your project and execute the same code.