// This only is triggered for errors from BTR.Excel.Signatures functions in Excel cells. (not called in VBA calls to VBAHelpers or errors from Ribbon) private object unhandledExceptionHandler( object exception ) { var caller = (ExcelReference)XlCall.Excel(XlCall.xlfCaller); var worksheetName = (string)XlCall.Excel( ExcelDna.Integration.XlCall.xlSheetNm, caller ) + "!"; //[Workbook]Sheet var address = worksheetName + RBLeHelpers.GetExcelA1Address( caller.RowFirst + 1, caller.ColumnFirst + 1); ExcelDna.Logging.LogDisplay.WriteLine( address + " Error: " + exception.ToString() ); // Would like to configure whether or not I lock ( alertCalculationErrorLock ) { if ( !alertCalculationErrorQueued ) { alertCalculationErrorQueued = true; ExcelAsyncUtil.QueueAsMacro( () => { XlCall.Excel( XlCall.xlcAlert, "There was one or more errors during calculation. Please review the Diagnostic Display." ); lock ( alertCalculationErrorLock ) { alertCalculationErrorQueued = false; } } ); } } return ExcelError.ExcelErrorValue; }
I am trying to figure out how to conditionally call the LogDisplay method based on whether logging/tracing of Errors is turned on. I've read through https://github.com/Excel-DNA/ExcelDna/wiki/Diagnostic-Logging but it isn't clicking with me on how to configure and check the configuration to determine if I should call the WriteLine and alert box. Any help would be appreciated. Let me know if I can provide you any more information.