Exception when cancelling InsertPages

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

akurian
User
Posts: 9
Joined: Thu Jan 09, 2014 12:03 pm

Exception when cancelling InsertPages

Post by akurian »

Hi,

I am using the following code in my toolbar button handler to allow the user to use your InsertPages UI:

Code: Select all

object dataIn = null, dataOut = null;
viewer.DoVerb("Documents[0]", "InsertPages", dataIn, out dataOut, 0);
This works fine except for generating a COMException when the user clicks Cancel. Am I doing something wrong? Do I need to call this via BeginInvoke?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Exception when cancelling InsertPages

Post by Vasyl - PDF-XChange »

Hi akurian.
This works fine except for generating a COMException when the user clicks Cancel.
Please wrap each call of DoVerb(and any other our method) into try/except brackets. Because when user canceled the dialog then DoVerb returns the 'ERROR_USER_CANCEL' error-code and standard COM-stub generates an exception on that.
Maybe in your project compilation settings you are able to turn off the generating COM-exceptions for returned error-codes..

HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.