private void CallTaskPaneVisibleStateChange(NetOffice.OfficeApi._CustomTaskPane customTaskPaneInst) { try { foreach (TaskPaneInfo item in TaskPanes) { if (item.Pane == customTaskPaneInst) { try { ITaskPane target = item.Pane.ContentControl as ITaskPane; if (null != target && item.Pane == customTaskPaneInst) { try { target.OnVisibleStateChanged(item.Pane.Visible); } catch (Exception exception) { Factory.Console.WriteException(exception); } } } catch (Exception exception) { Factory.Console.WriteException(exception); } } } TaskPaneVisibleStateChanged(customTaskPaneInst); } catch (Exception exception) { Factory.Console.WriteException(exception); } }