My addin is written in c#, NetOffice, ExcelDNA using WPFframework. Some part uses winforms, too. The main UI is WPF
When there is a modal dialog displayed, users force close Excel. Next time when they launch excel, Excel will say " Excel experienced a serious problem with the '*' add-in. If you have seen this message multiple times, you should disable this add0in and checke to see if an update is available. Do you want to disable this add-in?"
Yes, No
Users usually click Yes or enter without reading the message and then my add-in disappears from Excel. So I do not want this dialog to show up. Is it possible and how? thanks
I try to catch all exception in AutoOpen() like below. But it seems have no effect to stop the dialog at all.
public void AutoOpen()
{
.....
System.Windows.Forms.Application.ThreadException += ApplicationOnThreadException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
Dispatcher.CurrentDispatcher.UnhandledException += CurrentDispatcher_UnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
....
}
public void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
Helper.LogError(e.Exception);
}
public void ApplicationOnThreadException(object sender, ThreadExceptionEventArgs threadExceptionEventArgs)
{
Helper.LogError(threadExceptionEventArgs.Exception);
}
public void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs args)
{
if (!(args.ExceptionObject is ThreadAbortException))
{
Exception exc = args.ExceptionObject as Exception;
Helper.LogError(exc);
}
}
public void CurrentDispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
Helper.LogError(e.Exception);
e.Handled = true;
}