none
Outlook 2010 issue. Drag-n-drop onto a custom task pane causes Selection.Count to grow

    Question

  • Hello,
    We have an issue reported by our customer. I reproduced the issue in the project described below.
    The project. The project is downloadable here, file size = 16 969. This is an Outlook 2010 add-in project in VSTO 2010. The code in ThisAddin.vb:
    Public Class ThisAddIn
        Private WithEvents explorer As Outlook.Explorer
        Private ctp As Microsoft.Office.Tools.CustomTaskPane
    
        Private Sub ThisAddIn_Startup() Handles Me.Startup
            explorer = Application.ActiveExplorer()
            ctp = Me.CustomTaskPanes.Add(New UserControl1(), "Title")
            ctp.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight
            ctp.Visible = True
        End Sub
    
        Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
            Me.CustomTaskPanes.Remove(ctp)
            System.Runtime.InteropServices.Marshal.ReleaseComObject(explorer)
        End Sub
    
        Private Sub explorer_SelectionChange() Handles explorer.SelectionChange
            Dim selection As Outlook.Selection = explorer.Selection
            System.Diagnostics.Debug.WriteLine("!!! selection.Count=" + selection.Count.ToString())
            Dim res As Integer
            res = System.Runtime.InteropServices.Marshal.ReleaseComObject(selection)
            System.Diagnostics.Debug.WriteLine("!!! res=" + res.ToString())
        End Sub
    End Class
    

    UserControl1.vb
    Public Class UserControl1
    
        Private Sub UserControl1_DragEnter(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
            e.Effect = Windows.Forms.DragDropEffects.All
        End Sub
    
        Private Sub UserControl1_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
    
        End Sub
    End Class
    

    InitializeComponent in UserControl1.Designer.vb:
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Me.SuspendLayout()
            '
            'UserControl1
            '
            Me.AllowDrop = True
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.Name = "UserControl1"
            Me.ResumeLayout(False)
    
        End Sub
    

    The issue. Start Outlok 2010 SP 1 32-bit. In the explorer window, drag an item onto the custom task pane; you may be required to drop one more item. Now start selecting items and check the selection.Count. The result: selection.Count grows while you select new items. The expected behavior: selection.Count should return the number of items actually selected in the explorer.
    In my tests, the Navigation pane was Normal, the To-Do Bar was Normal, the Reading pane was Off.
    Note. If the Reading Pane is shown, it freezes after drag-n-drop. Because we reported the Outlook team about Reading Pane freezing after drag-n-drop in Outlook 2010 32-bit a while back, the current issue seems to be just another manifestation of the same bug. However, I didn't test the current issue in Outlook 2010 64-bit, sorry.

    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    Monday, September 26, 2011 3:12 PM

All replies