Outlook AddIn“PropertyPage”未显示在 Outlook 选项中

Outlook AddIn `PropertyPage` not showing up in Outlook Options

我有一个 Outlook 2007 加载项项目,我正在尝试向其添加 PropertyPage。我已经实现了 OptionsPage class(实现了 PropertyPage),它是在 Application.OptionsPagesAdd 事件期间添加的。

Public Class OptionsPage
    Implements Microsoft.Office.Interop.Outlook.PropertyPage

    Private Sub Me_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        System.Windows.Forms.MessageBox.Show("Test Options Loaded")
    End Sub

    Public Sub Apply() Implements Microsoft.Office.Interop.Outlook.PropertyPage.Apply
        ' todo
    End Sub

    Public ReadOnly Property Dirty As Boolean Implements Microsoft.Office.Interop.Outlook.PropertyPage.Dirty
        Get
           ' todo
            Return False
        End Get
    End Property

    Public Sub GetPageInfo(ByRef HelpFile As String, ByRef HelpContext As Integer) Implements Microsoft.Office.Interop.Outlook.PropertyPage.GetPageInfo
        ' todo
    End Sub

End Class
Public Class ThisAddIn

    Private Sub Application_OptionsPagesAdd(pages As Microsoft.Office.Interop.Outlook.PropertyPages) Handles Application.OptionsPagesAdd
        pages.Add(New OptionsPage(), "Test Options")
    End Sub

End Class

谁能告诉我为什么我无法让 OptionsPage 显示在 Outlook 的选项中,即使我没有收到任何错误或运行时异常?

您需要创建一个实现 PropertyPage interface. See How to implement OL PropertyPage with c# 的用户控件以获取更多信息。

请注意,如果您不懂 C#,可以使用 automatic language converters 获取 VB.NET 代码。

事实证明,您需要确保 class(实现 PropertyPage)的 ComVisible 属性设置为 True 才能在 Outlook 中显示- 发现 in this thread

<System.Runtime.InteropServices.ComVisible(True)>
Public Class OptionsPage
    Implements Microsoft.Office.Interop.Outlook.PropertyPage
End Class