I'm posting the entire block to show the code that's being used. I'm going to
test what you mentioned to see what happens. Will post back in a couple
minutes.
Private Sub m_olInspectors_NewInspector(ByVal Inspector As
Microsoft.Office.Interop.Outlook.Inspector) Handles
m_olInspectors.NewInspector
Dim inspectorWrapper As InspectorWrapper = Nothing
Dim oMailItemTest As Outlook.MailItem = Nothing
Dim strLoginFailed As String = ""
Try
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
oMailItemTest = CType(Inspector.CurrentItem, Outlook.MailItem)
'Determine if a New Mail is being composed
If IsNothing(oMailItemTest.EntryID) Then
inspectorWrapper = New InspectorWrapper(Inspector,
inspectorID, False)
'Uses the inspector key to reference the wrapper object
in the collection when added
InspectorList.Add(inspectorWrapper,
CStr(inspectorWrapper.Key), True)
'Increment to give each wrapper object a unique ID
inspectorID += 1
Else
'Web Service call to get client modules
If IsNothing(g_sXMLModules) Then
g_sXMLModules = New XmlDocument
If (g_blnSuccess) Then
g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
"Outlook"))
Else
AutoLoginClick(True)
WriteLog("clsOutlookAddIn.vb LIne 190: Automatic
logging successfully completed when attempting to load Outlook Modules when
the Modules XML is Nothing!")
If (g_blnSuccess) Then
g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
"Outlook"))
End If
End If
Else
If
IsNothing(g_sXMLModules.SelectSingleNode("DashboardList/Dashboard")) Then
If (g_blnSuccess) Then
g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
"Outlook"))
Else
AutoLoginClick(True)
WriteLog("Automatic logging successfully
completed when attempting to load Outlook Modules when the webservice
populates the Modules XML!")
If (g_blnSuccess) Then
g_sXMLModules.LoadXml(WebServiceProxy.GetDashboardModules(g_sToken,
"Outlook"))
End If
End If
End If
End If
inspectorWrapper = New InspectorWrapper(Inspector,
inspectorID, True)
InspectorList.Add(inspectorWrapper,
CStr(inspectorWrapper.Key), False)
inspectorID += 1
End If
End If
Catch ex As SystemException
MessageBox.Show(ex.Message)
WriteLog("clsOutlookAddIn.vb Line 217: New Inspector event
handler failed to run: " & ex.Message)
Finally
inspectorWrapper = Nothing
oMailItemTest = Nothing
Inspector = Nothing
End Try
End Sub
wrote:
> It's also been bugged to the Outlook team, with a repro found (even in VBA),
> and it's being investigated.
> >
>
> " - " <kenslovak@mvps.org> wrote in message
> news:O7pci%23dvJHA.4364@TK2MSFTNGP03.phx.gbl...
> > OK, I did some testing on this and from what I found here it appears that
> > accessing Inspector.CurrentItem directly or indirectly at all without
> > later fully releasing that object will cause this error.
> > For example, assuming your NewInspector() code has just this line in it:
> > If (TypeOf(Inspector.CurrentItem) Is Outlook.MailItem) Then
> > That will cause this error.
> > So will this line:
> > Dim currentOLItem As Object = Inspector.CurrentItem
> > However, if you use these lines the problem seems to go away:
> > Dim currentOLItem As Object = Inspector.CurrentItem
> > If (TypeOf(currentOLItem) Is Outlook.MailItem) Then
> > ' whatever code you want
> > End If
> > Marshal.ReleaseComObject(currentOLItem)
> > currentOLItem = Nothing
> > I haven't seen the problem when opening Outlook items within Outlook, it
> > seems to occur for MSG items however, no matter where they're stored. A
> > network share or whatever is not required to cause the problem.
> > See if explicitly instantiating an object for Inspector.CurrentItem so you
> > have control over it, and then fully releasing it solves the problem for
> > you. Please post back on your results, if you still have the problem I'll
> > take it up with the Outlook team.
> > > >
> >
> > "Andrew" <Andrew> wrote in message
> > news:CB6CEABF-A3CD-49B4-9DA0-500728CFBCFF@microsoft.com...
> >> Hey,
> >
> >> It fires in every case, Run Mode, Debug mode and when deployed to a
> >> machine.
> >> It opens once and then is broken after that.
> >
> >> The email is being opened from a Windows Explorer browser by the user,
> >> double-clicking it.
> >
> >> Here's the initial part of the code that traps the event:
> >
> >> global variable
> >> Dim WithEvents m_olInspectors As Outlook.Inspectors
> >> InspectorWrapper is a custom class
> >
> >> Private Sub m_olInspectors_NewInspector(ByVal Inspector As
> >> Microsoft.Office.Interop.Outlook.Inspector) Handles
> >> m_olInspectors.NewInspector
> >> Dim inspectorWrapper As InspectorWrapper = Nothing
> >> Dim oMailItemTest As Outlook.MailItem = Nothing
> >
> >> Try
> >> .....
> >> Catch ex As SystemException
> >> MessageBox.Show(ex.Message)
> >> WriteLog("clsOutlookAddIn.vb Line 217: New Inspector event handler failed
> >> to
> >> run: " & ex.Message)
> >> Finally
> >> inspectorWrapper = Nothing
> >> oMailItemTest = Nothing
> >> End Try
> >> End Sub
> >
> >> Regards,
> >
>