[Mono-bugs] [Bug 349655] New: ListControl etc: AOOREx on first add to bound IBindingList

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Dec 18 17:30:35 EST 2007


https://bugzilla.novell.com/show_bug.cgi?id=349655


           Summary: ListControl etc: AOOREx on first add to bound
                    IBindingList
           Product: Mono: Class Libraries
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: andyhume32 at yahoo.co.uk
         QAContact: mono-bugs at ximian.com
          Found By: ---


With code of the following form ComboxBox/ListControl throw
ArgumentOutOfRangeException when first adding to the list
[[
   IBindindList ibl = new BindingList<int32>();
   ComboBox cb = new ComboBox()
   cb.DataSource = ibl;
   // ...
   // list is empty and bound, first add -> exception
   ibl.Add(99); //**
]]

Note that except for this particular case the data binding seems to work well
for my purposes.  Adding items updates any bound controls, navigating the list
in one control causes navigation in the others, etc.  So fixing this corner
case would allow one to use this functionality.

The sample app can be configured to start with an non-empty list (give it any
dummy command-line option) and you'll see the working behaviour.  Run without
any command-line options hit <Do Fill> and see the exception.


The exception in full is
[[
Unhandled Exception: System.ArgumentOutOfRangeException: Argument is out of
range.
Parameter name: SelectedIndex0
at System.Windows.Forms.ComboBox.set_SelectedIndex (int) [0x000c8] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\ComboBox.cs:651
at System.Windows.Forms.ListControl.OnPositionChanged (object,System.EventArgs)
[0x0000b] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\ListControl.cs:504
at (wrapper delegate-invoke)
System.MulticastDelegate.invoke_void_object_EventArgs (object,System.EventArgs)
<0x00040>
at (wrapper delegate-invoke)
System.MulticastDelegate.invoke_void_object_EventArgs (object,System.EventArgs)
<0x00067>
at System.Windows.Forms.CurrencyManager.OnPositionChanged (System.EventArgs)
[0x0000b] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\CurrencyManager.cs:283
at System.Windows.Forms.CurrencyManager.ChangeRecordState
(int,bool,bool,bool,bool) [0x00068] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\CurrencyManager.cs:334
at System.Windows.Forms.CurrencyManager.ListChangedHandler
(object,System.ComponentModel.ListChangedEventArgs) [0x000e0] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\CurrencyManager.cs:409
at System.ComponentModel.BindingList`1.OnListChanged
(System.ComponentModel.ListChangedEventArgs) [0x0000b] in
D:\cygwin\usr\src\mono\mcs\class\System\System.ComponentModel\BindingList.cs:256
at System.ComponentModel.BindingList`1.InsertItem (int,System.Version)
[0x0001f] in
D:\cygwin\usr\src\mono\mcs\class\System\System.ComponentModel\BindingList.cs:244
at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Add
(object) [0x0000c] in
D:\cygwin\usr\src\mono\mcs\class\corlib\System.Collections.ObjectModel\Collection.cs:209
at ListControlIBindingList.buttonDoFill_Click (object,System.EventArgs)
<0x00034>
at System.Windows.Forms.Control.OnClick (System.EventArgs) [0x0001c] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Control.cs:5651
at System.Windows.Forms.Button.OnClick (System.EventArgs) [0x00024] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Button.cs:104
at System.Windows.Forms.ButtonBase.OnMouseUp
(System.Windows.Forms.MouseEventArgs) [0x00076] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\ButtonBase.cs:616
at System.Windows.Forms.Button.OnMouseUp (System.Windows.Forms.MouseEventArgs)
[0x00000] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Button.cs:126
at System.Windows.Forms.Control.WmLButtonUp (System.Windows.Forms.Message&)
[0x0005c] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Control.cs:5247
at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message&)
[0x0017c] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Control.cs:5000
at System.Windows.Forms.ButtonBase.WndProc (System.Windows.Forms.Message&)
[0x00055] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\ButtonBase.cs:674
at System.Windows.Forms.Button.WndProc (System.Windows.Forms.Message&)
[0x00000] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Button.cs:148
at ControlWindowTarget.OnMessage (System.Windows.Forms.Message&) [0x00000] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Control.cs:225
at ControlNativeWindow.WndProc (System.Windows.Forms.Message&) [0x00000] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Control.cs:206
at System.Windows.Forms.NativeWindow.WndProc
(intptr,System.Windows.Forms.Msg,intptr,intptr) [0x0006a] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\NativeWindow.cs:188
at System.Windows.Forms.XplatUIWin32.InternalWndProc
(intptr,System.Windows.Forms.Msg,intptr,intptr) [0x0002c] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\XplatUIWin32.cs:1886
at (wrapper native-to-managed)
System.Windows.Forms.XplatUIWin32.InternalWndProc
(intptr,System.Windows.Forms.Msg,intptr,intptr) <0x00065>
at (wrapper managed-to-native)
System.Windows.Forms.XplatUIWin32.Win32DispatchMessage
(System.Windows.Forms.MSG&) <0x00004>
at System.Windows.Forms.XplatUIWin32.DispatchMessage
(System.Windows.Forms.MSG&) [0x00000] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\XplatUIWin32.cs:2081
at System.Windows.Forms.XplatUI.DispatchMessage (System.Windows.Forms.MSG&)
[0x00000] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\XplatUI.cs:551
at System.Windows.Forms.Application.RunLoop
(bool,System.Windows.Forms.ApplicationContext) [0x0033e] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Application.cs:842
at System.Windows.Forms.Application.Run
(System.Windows.Forms.ApplicationContext) [0x00014] in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Application.cs:630
at System.Windows.Forms.Application.Run (System.Windows.Forms.Form) [0x00000]
in
D:\cygwin\usr\src\mono\mcs\class\Managed.Windows.Forms\System.Windows.Forms\Application.cs:618
at ListControlIBindingList.Foo (bool) <0x001ec>
at ListControlIBindingList.Main (string[]) <0x00045>
]]

The same occurs if using a ListBox too.

Repro is
[[
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

class ListControlIBindingList
{
        static void Main(string[] args)
        {
                bool nonEmptyWhenBound = false;
                //
                if (args.Length > 0)
                        nonEmptyWhenBound = true;
                //
                Foo(nonEmptyWhenBound);
        }

        static IBindingList m_ibl;

        static void buttonDoFill_Click(object sender, EventArgs e)
        {
                // The bug occurs here, the list is empty and bound, 
                // now add an item to it.  Crash.  Occurs when empty list ->
item added.
                m_ibl.Add(new Version(3, 1));
                m_ibl.Add(new Version(3, 2));
                m_ibl.Add(new Version(3, 3));
        }

        private static void Foo(bool nonEmptyWhenBound)
        {
                Form f = new Form();
                f.Text = "ListControlIBindingList";
                FlowLayoutPanel flp = new FlowLayoutPanel();
                f.Controls.Add(flp);
                //
                m_ibl = new BindingList<Version>();
                bool skipBug = false || nonEmptyWhenBound;
                if (skipBug) {
                        m_ibl.Add(new Version(0, 99));// NON-EMPTY at bound Add
                }
                //
                ListControl cb = new ComboBox();
                cb.DataSource = m_ibl;
                flp.Controls.Add(cb);
                //
                Button b = new Button();
                b.Text = "Do Fill";
                b.Click += buttonDoFill_Click;
                flp.Controls.Add(b);
                //
                //cb = new ComboBox();
                cb = new ListBox();
                cb.DataSource = m_ibl;
                flp.Controls.Add(cb);
                //
                Application.Run(f);
        }

}//class
]]


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list