locked
Outlook doesnt release Inspector RRS feed

  • Question


  • Hi ,

    I am sorry for writing my problem again here, but I have to find urgent a solution.

    Do you have any idea about this problem:
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1437968&SiteID=1

    I also tried it with a new empty outlook addin project under VSTO 2005 SE (Outlook 2003 SP2), but the result is same. I can not open a msg file for a second time.



    Many thanks in advanced
    Thursday, July 3, 2008 10:21 AM

Answers

  • Hi Tuncali,

     

    I am afraid the behavior you saw does not result from above codes. I tried your codes on my end and debug it, but I find that NewInspector event never fires. I noticed that you did not initialize myInspectors variable. That is to say this Add-in did nothing. So, my guess is what you see is caused from the privouse problematical Add-in you did not disable.

    I suggest you disable all previouse Add-ins, and try the following codes:

    Code Snippet

    Public Class ThisAddIn

        Private WithEvents myInspectors As Outlook.Inspectors

        Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
            myInspectors = Me.Application.Inspectors
        End Sub

        Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown

        End Sub

        Private Sub myInspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles myInspectors.NewInspector
            '------------------------------------------------------------
            Dim item As Outlook.MailItem = Inspector.CurrentItem
            MessageBox.Show(item.Body)
            item = Nothing
            GC.Collect()
            GC.WaitForPendingFinalizers()
            GC.Collect()
            '------------------------------------------------------------
        End Sub
    End Class

     


    It works fine on my side.

     

     

    Thanks,

    Ji

    Tuesday, July 8, 2008 3:09 AM

All replies

  • Is this a bug in Outlook 2003?

    I tried same issue under Outlook 2007 with using VSTO 2005 SE again, and it works.



    I also installed Outlook 2003's SP3 but it doesnt have matter. Same problem again
    Friday, July 4, 2008 11:56 AM
  • Hi,

     

    Have you tried to have a second call to GC.Collect() after calling GC.WaitForPendingFinalizers()?

    Like:

    '------------------------------------------------------------
    Dim item as Outlook.MailItem
    ...
    item=nothing
    GC.Collect()
    GC.WaitForPendingFinalizers()

    GC.Collect()
    '------------------------------------------------------------

    GC.WaitForPendingFinalizers() only guarantees all Finalizer() method will be called before the calling thread goes on. But the memory will not be collected until the second GC.Collect() is called.

    Hope this helps!

     

     

    Thanks,

    Ji

    Monday, July 7, 2008 8:34 AM
  • Hi Ji,

    Thanks for your answer, but it doesnt work :-(

    I created a new project again, there is no extra code in project, but it still doesnt work. Here you can see the code sample.

    Code Snippet

    public class ThisAddIn

        Private WithEvents myInspectors As Outlook.Inspectors

        Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup

        End Sub

        Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown

        End Sub

        Private Sub myInspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles myInspectors.NewInspector
            '------------------------------------------------------------
            Dim item As Outlook.MailItem

            item = Nothing
            GC.Collect()
            GC.WaitForPendingFinalizers()

            GC.Collect()
            '------------------------------------------------------------
        End Sub
    End Class



    Thanks,
    tuncali
    Monday, July 7, 2008 9:56 AM
  • Hi Tuncali,

     

    I am afraid the behavior you saw does not result from above codes. I tried your codes on my end and debug it, but I find that NewInspector event never fires. I noticed that you did not initialize myInspectors variable. That is to say this Add-in did nothing. So, my guess is what you see is caused from the privouse problematical Add-in you did not disable.

    I suggest you disable all previouse Add-ins, and try the following codes:

    Code Snippet

    Public Class ThisAddIn

        Private WithEvents myInspectors As Outlook.Inspectors

        Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
            myInspectors = Me.Application.Inspectors
        End Sub

        Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown

        End Sub

        Private Sub myInspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles myInspectors.NewInspector
            '------------------------------------------------------------
            Dim item As Outlook.MailItem = Inspector.CurrentItem
            MessageBox.Show(item.Body)
            item = Nothing
            GC.Collect()
            GC.WaitForPendingFinalizers()
            GC.Collect()
            '------------------------------------------------------------
        End Sub
    End Class

     


    It works fine on my side.

     

     

    Thanks,

    Ji

    Tuesday, July 8, 2008 3:09 AM
  • Hi Ji,

    Thanks for your help, it works fine, of course after I deactivated all 3 party addins. There was a problem within a 3 party addin.


    Thanks again,
    Tuncali
    Tuesday, July 8, 2008 1:18 PM