gpt4 book ai didi

c# - Outlook 2010 Com 加载项 - NewExplorer 永远不会触发

转载 作者:太空狗 更新时间:2023-10-30 01:08:23 24 4
gpt4 key购买 nike

出于某种原因,在我的应用程序中,我的 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);
}

最佳答案

对于您在使用 VSTO 时想要保留的任何事件,您需要保留一个类级成员(ExplorerApplicationInspectorCommandBar)以防止 GC 线程删除它们。这是一种资源优化,但也可能是一个惨痛的教训。

查看相关MSDN Forum post regarding event lifetimesimilar SO post .

关于c# - Outlook 2010 Com 加载项 - NewExplorer 永远不会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9537330/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com