A first chance exception of type 'System.InvalidOperationException' occurred in Aspose.Words.DLL

I am trying to convert a 300 page word document into pdf. The document it self is simple text no bells and whistles. This is performance testing we are doing. The code iteself never throws an exception but the page times out because the error. When I had a look at the immediate window in I saw a few hundred of these messages.

A first chance exception of type ‘System.InvalidOperationException’ occurred in Aspose.Words.DLL

Is there a limit to how many pages your product could handle. I tried to see if I can divide the pages into separate documents, but the page count call also throwed same exceptions.

Please let me know asap as we are evaluating your product.

Hi there,
Thanks for considering Aspose.
Are you able to attach your documents here for testing? I will look into why this exception is occuring.
Thanks,

Hi

Thanks for your inquiry. No, there are no limits. There might be something wrong with your document. So, please attach it here for testing. I will check it and provide you more information.
Best regards,

I added the attachment.

Hi there,
Thanks for this additional information.
I think Alexey is right when he suggested that there is something wrong with your document. Could you provide some details about how this document was created?
If I copy the content from your document into a brand new document and convert that using Aspose.Words the document object throws no exceptions. Please note that rendering takes about 30 seconds due to the number of pages in your document.
You may also want to think about splitting your documents if they are that large, as MS Word has trouble working with documents with that many pages.
Thanks,

The documents were created using Office 2010. Is it not fully supported?

Hi

Thank you for additional information. I cannot reproduce the problem on my side. I can successfully convert your document to PDF on my side. I use the latest version of Aspose.Words for testing. You can download it from here:
https://releases.aspose.com/words/net
Which version of Aspose.Words do you use?
Best regards,

Your colleague was able to. Please look at reply 262262

Hi
Thank you for additional information. I also unable to reproduce the problem with your document on my side. Adam, have you managed to reproduce the problem on your side?
Also Syam, which version of Aspose.Words you are using?
Best regards,

The latest version 9.4.0.0

Hi there,
Thanks for your inquiry.
I was able to reproduce the timing out of certain properties when debugging. Please see the screen shot below. Is this the sort of error you are encountering? None appeared to throw any internal exceptions on my side though.
``
I looked into this behaviour a little closer and it seemed it’s just a quirk of the debugger. The PageCount property is calucated by invoking the UpdatePageLayout method. This method lays out the document into lines and pages. Depending upon the number of pages in your document this action can take a while (Aspose.Words generally renders around 10 pages a second).
In the debugger, if a member of an object takes too long to evaluate it will display this error and stop evaluating any further properties (even in different instances of the same class type). This appears to be what is happening here with the PageCount property as this error only occurs with documents that have a large number of pages (thus are taking to long to evaluate and “time out”). This behaviour in the debuger can be avoided by calling UpdatePageLayout method or using the PageCount property and waiting for this to finish before viewing the properties in the debugger.
As you said in your first post, no exception is actually being thrown so most likely there is no issue unless you actually have an exception halting your applicaiton. The timing out you are experiencing is probably just due to you not waiting long enough for this process to finish. Your docment is very large, depending on your processor speed, invoking the PageCount property for the first time you may need to wait up to a few minutes for this document to be “layed out” and the property to return a value.
If you have any further issues, please feel free to ask.
Thanks,