首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >C# Outlook抛出异常

C# Outlook抛出异常
EN

Stack Overflow用户
提问于 2015-09-16 15:05:04
回答 1查看 254关注 0票数 0

我正在用VSTOoutlook开发一个插件,我试图将一个单独的表单区域显示为打开的检查器中的当前表单页面,但会抛出一个异常。这是代码

代码语言:javascript
复制
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        this.Application.Inspectors.NewInspector += InspectorsOnNewInspector;
        this.Application.Explorers.NewExplorer +=  Explorers_NewExplorer;
    }

    private void Explorers_NewExplorer(Outlook.Explorer explorer)
    {

    }

    private void InspectorsOnNewInspector(Outlook.Inspector inspector)
    {
        MessageBox.Show("ola");
        // exception ocurrs in this line 
        inspector.SetCurrentFormPage("OutlookAddIn.RequestFormRegion");

    }

    private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
    {
    }

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2015-09-16 15:58:41

我设法让它使用下面的代码

代码语言:javascript
复制
 private void InspectorsOnNewInspector(Outlook.Inspector inspector)
    {

        MessageBox.Show("ola");

        if (!(inspector.CurrentItem is Outlook.TaskItem)) return;

        var taskItem = (Outlook.TaskItem) inspector.CurrentItem;

        taskItem.Open += (ref bool cancel) =>
        {
            try
            {
                inspector.SetCurrentFormPage("OutlookAddIn.RequestFormRegion");

            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        };
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32612339

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档