为了账号安全,请及时绑定邮箱和手机立即绑定

为什么 CustomTaskPane 抛出空异常

为什么 CustomTaskPane 抛出空异常

C#
qq_花开花谢_0 2021-06-03 14:41:43
我正在创建 VSTO插件并且我已经尝试将 winform 插件添加到 Word 中的自定义任务窗格, 但它抛出了 NullReferenceException。        CustomTaskPaneCollection CustomTaskPanes;        CustomTaskPane ct;        Pdfcontrol pdf = new Pdfcontrol();        ct = Globals.ThisDocument.CustomTaskPanes.Add(pdf, "Pdf");
查看完整描述

1 回答

?
临摹微笑

TA贡献1982条经验 获得超2个赞

ThisDocument没有CustomTaskPanes属性,这甚至不应该编译。您得到的答案是针对应用程序级加载项,而您有一个文档级加载项。在你的情况下,你想这样做:


Pdfcontrol pdf = new Pdfcontrol();

Globals.ThisDocument.ActionsPane.Controls.Add(pdf)


查看完整回答
反对 回复 2021-06-05
  • 1 回答
  • 0 关注
  • 113 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号