I have an Excel Add-in using shared runtme which has some ribbon buttons and one of the ribbon button is used to open a dialog. However if user clicks this button frequantly, I am getting this error ""An internal error has occurred." and no page is loaded in dialog. Even right click on dialog does not show context menu which is usually shown when page is loaded. First image shows empty dialog opened.
Second Image shows debug breakpoint hit and error message I got in host taskpane. asyncResult.error.code has value "-2147467259".
Any idea how to avoid this situation?
EDIT: code in ribbon event handler:
if(dialog)dialog.close();// close previously opened dialog. here dialog is reference of previously opened dialog if any
Office.context.ui.displayDialogAsync(urlp,
{ height: height, width: width, displayInIframe: true }, dialogCallbackIFrame);
event.completed();
You need to wait a bit until the previous dialog is closed. Try to add some delay before calling the displayDialogAsync
method.