Globals.ThisAddIn.Application.ActiveInspector == null虽然显示有效的Outlook.AppointmentItem为什么?

问题描述 投票:0回答:1

我正在使用VSTO开发一个outlook插件。

在方法中:this.Load + = new Microsoft.Office.Tools.Ribbon.RibbonUIEventHandler(this.MyApp_Load);

在我的功能区的MyApp_Load中,我使用以下代码:

if (Globals.ThisAddIn.isLoggedIn())
{
    btnMyApp.Visible= true;
    Outlook.Inspector inspector = 
         Globals.ThisAddIn.Application.ActiveInspector();
    if (inspector != null && inspector.CurrentItem != null)
    {

当我在Outlook中打开一个AppointmentItem时,我可以调试上面的代码。不幸的是,虽然正在显示有效的AppointmentItem,但ActiveInspector()== null。

为什么?

vsto outlook-addin
1个回答
0
投票

在显示检查器之前调用该方法。你必须使用RibbonUI作为参数传递给你的onLoad回调并将RibbonUI.Context投射到Inspector界面。

© www.soinside.com 2019 - 2024. All rights reserved.