none
IDTExtensibility2:OnBeginShutdown事件发生时application对象已经销毁? RRS feed

  • 问题

  • 做了个Outlook Addin需要在OnBeginShutdown事件发生时记录toolbar的位置和状态。
    但为什么无法取得CommandBars?

    public void OnBeginShutdown(ref System.Array custom)

    {

    CommandBars oCommandBars;

    try

    {

    oCommandBars = (CommandBars)applicationObject.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, applicationObject, null);

    }

    catch (Exception)

    {

    // Outlook has the CommandBars collection on the Explorer object.

    object oActiveExplorer;

    oActiveExplorer = applicationObject.GetType().InvokeMember("ActiveExplorer", BindingFlags.GetProperty, null, applicationObject, null);

    oCommandBars = (CommandBars)oActiveExplorer.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, oActiveExplorer, null);

    }

    }


    2008年1月29日 9:21

答案

全部回复