vsto - Globals.ThisAddIn.Application.ActiveInspector == null 虽然显示了有效的 Outlook.AppointmentItem 为什么?
问题描述
我正在使用 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 时,我可以调试上面的代码。不幸的是 ActiveInspector() == null 尽管正在显示有效的 AppointmentItem。
为什么?
解决方案
在显示检查器之前调用该方法。您必须使用RibbonUI
传递作为onLoad
回调的参数并RibbonUI.Context
转换为Inspector
接口。
推荐阅读
- razor - Umbraco 画廊创建部分
- python - 如何处理python烧瓶路由中的http状态码
- json - Jackson 无法反序列化 Optional,抛出 NoSuchFieldError
- dht - 来自其他节点的主线 DHT 意外消息
- javascript - 在 powerbi 插件中使用传单地图的问题
- robotframework - 如何使用机器人框架选择包含文本的元素?
- bash - 脚本中的 sshpass 和 svn commit:脚本手动运行时有效,使用 Cron 运行时失败
- java - Java程序在设备上没有剩余空间
- python-3.x - 我不确定检测到的错误是什么语法
- css - 重叠的容器