InvalidCastOperation when using Paginator in cancelled thread

Hi GemBox Team,

I have a question regarding the paginator.
My application loads a document from a file and then uses “GetPaginator()” to receive the pages. If this operation takes longer than a configured amount of seconds, the thread is aborted. When I implement a specific document, I receive the following exception:

{
    "Type": "System.InvalidCastException",
    "TargetSite": "System.Object ChkCast_Helper(Void*, System.Object)",
    "Message": "Unable to cast object of type '\\u0002\\u001a\\u0002' to type '\\u0002\\u0002\\u0002'.",
    "Data": {},
    "Source": "System.Private.CoreLib",
    "HResult": -2147467262,
    "StackTrace": "   
    at \\b\\u0018\\u000f.\\u000e\\u0016(\\u000f\\u0019\\u0002 \\u000f, \\b\\u0016\\u0002& \\b, Int32& \\u0006)\\n   
    at \\b\\u0018\\u000f.\\u0006\\u0016(\\u000f\\u0019\\u0002 \\u000f)\\n   
    at \\u0002\\u000f\\u0019.\\u000e\\u0002()\\n   
    at \\u0005\\u0010\\u0019.\\u0005\\u0019()\\n   
    at GemBox.Document.DocumentModel.\\b\\u001b(PaginatorOptions \\u000f, \\u000f\\u0018\\u0015\\u0018 \\b, \\u0005\\u0005\\u0010\\u0018 \\u0006, Boolean \\u0002)\\n   
    at GemBox.Document.DocumentModel.GetPaginator()\\n   
    at ..."
}

Is this due to potentially cancelling the GetPaginator() method? Or could this be a problem with the document?

Note: when I load the document in an example project without a cancellable thread, the paginator can be used as expected. Therefore the problem is not really easy to reproduce.

Kind regards,
Sarah

Are both projects using the same bugfix version of GemBox.Document?

This issue seems to be specific to the document, not to the cancellable thread. Can you send us that document so we can investigate it?

Hi Mario,

both are using version 51.0.1049-hotfix of GemBox.Bundle.
You can download the file here: Unique Download Link | WeTransfer

Hi Sarah,

Can you please try again with the current latest version of GemBox.Bundle:

Install-Package GemBox.Bundle -Version 51.0.1104

Does this solve your issue?

Regards,
Mario

1 Like

Hi Mario,

The issue does not appear anymore in the new version. Thank you!

Regards,
Sarah