我有一個啓動時加載的VSTO Outlook 2007插件。當它加載它的follwing:爲什麼我的VSTO Outlook加載項啓動兩次?
Private Sub ThisAddIn_Startup() Handles Me.Startup
explorer = Me.Application.ActiveExplorer()
AddHandler Application.ItemContextMenuDisplay, AddressOf Application_ItemContextMenuDisplay
AddHandler Application.Startup, AddressOf Application_CommandBarMenuDisplay
End Sub
然後這個AddHandlers後執行以下操作:
Sub Application_CommandBarMenuDisplay()
Dim cBar As Office.CommandBar = explorer.CommandBars("Standard")
btnCommandBarMenu = CType(cBar.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, True), Office.CommandBarButton)
With btnCommandBarMenu
.BeginGroup = True
.Style = MsoButtonStyle.msoButtonIconAndCaption
.Caption = "File TNRP Email"
.Tag = "File TNRP Email"
.Picture = IPictureDisp.FromImage(My.Resources.label16)
.Mask = IPictureDisp.MaskFromImage(My.Resources.label16)
End With
AddHandler btnCommandBarMenu.Click, AddressOf btn_CommandBarMenuClick
End Sub
Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Microsoft.Office.Core.CommandBar, ByVal Selection As Microsoft.Office.Interop.Outlook.Selection)
btnContextMenu = CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, True)
With btnContextMenu
.BeginGroup = True
.Visible = True
.Style = MsoButtonStyle.msoButtonIconAndCaption
.Caption = "File TNRP Email"
.Tag = "File TNRP Email"
.Picture = IPictureDisp.FromImage(My.Resources.label16)
.Mask = IPictureDisp.MaskFromImage(My.Resources.label16)
End With
AddHandler btnContextMenu.Click, AddressOf btn_ContextMenuClick
End Sub
當發送電子郵件的應用程序工作正常。但是,當我點擊按鈕時,添加火焰發生兩次,當我使用上下文菜單時,它也會發射兩次。
任何想法,爲什麼這可能是?