AddHandler is not working

  • Thread starter Thread starter Dhananjay
  • Start date Start date
D

Dhananjay

Hi All,
I am creating VSTO COM addin for office 2003 with vb2005. I am trying
to simulate control array by using AddHandler. My code snippet of
NewInspector event is as follows.

'------------------------------------------------------------------------------------------
Private Sub myInspectors_NewInspector(ByVal Inspector As
Microsoft.Office.Interop.Outlook.Inspector) Handles
myInspectors.NewInspector
If
Inspector.CurrentItem.MessageClass.Contains(CustomMessageClassName)
Then
AddTrace("Inspectors' messageclass is - " &
Inspector.CurrentItem.MessageClass)
Try
myGlobalInspector = Inspector

currentContactItemInspCollection.Add(myGlobalInspector)
AddHandler myGlobalInspector.Activate, AddressOf
ActivateInspector
AddHandler myGlobalInspector.Close, AddressOf
CloseInspector
Catch ex As System.Exception
AddTrace("Exception while getting current inspector's
information - " & ex.Message)
MsgBox("Exception while getting current inspector's
information - " & ex.Message, MsgBoxStyle.Critical Or
MsgBoxStyle.SystemModal)
End Try
Else
AddTrace("Inspectors' messageclass is - " &
Inspector.CurrentItem.MessageClass)
End If
'------------------------------------------------------------------------------------------

My ActivateInspector just contains single line of trace. Now my
question is if I give breakpoint at AddHandler statement & by pressing
F10 I can see that my ActivateInspector procedure is fired perfectly.
But if I run the program without breakpoint, then my ActivateInspector
is never going to call. What is the problem?

Thanks,
Dhananjay
 
What happens if you switch the focus to a different app and then come back
to the inspector?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Back
Top