【发布时间】:2012-03-02 17:02:07
【问题描述】:
由于某种原因,在我的应用程序中,我的 FolderSwitch 在随应用程序打开的主资源管理器上工作,但 NewExplorer 事件从不触发,因此很明显 FolderSwitch 事件不会在新资源管理器上触发。
我不知道为什么事件没有触发。
private List<_Outlook.Explorer> ListOfExplorerWindows = new List<_Outlook.Explorer> { };
private _Outlook.Application Application;
public void OnConnection(object Application, Extensibility.ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
{
this.Application = (_Outlook.Application)Application;
}
public void OnStartupComplete(ref Array custom)
{
_Outlook.Explorer Explorer = this.Application.ActiveExplorer();
Explorer.FolderSwitch += new _Outlook.ExplorerEvents_10_FolderSwitchEventHandler(Explorer_FolderSwitch);
ListOfExplorerWindows.Add(Explorer);
this.Application.Explorers.NewExplorer += new _Outlook.ExplorersEvents_NewExplorerEventHandler(Explorers_NewExplorer);
}
private void Explorers_NewExplorer(_Outlook.Explorer Explorer)
{
Explorer.FolderSwitch += new _Outlook.ExplorerEvents_10_FolderSwitchEventHandler(Explorer_FolderSwitch);
ListOfExplorerWindows.Add(Explorer);
}
【问题讨论】:
-
其实我可能已经通过添加私有 _Outlook.Explorers Explorers 来修复它;在课堂上,但我认为私有 _Outlook.Application 应用程序;会保持在范围内,谁能解释一下?
-
我自己的信息:您在哪里绑定到 OnConnection 和 OnStartupComplete?什么对象有这些事件?
-
我不认为它们是事件,它们是接口IExtensibility2的公共方法