"System.ArgumentException: '0' is not a valid value for 'value'" Error Message in a Windows Forms Application (828347)



The information in this article applies to:

  • Microsoft .NET Framework 1.0 SP2

SYMPTOMS

If you populate a DataGrid control while a Microsoft Windows Form is minimized, you may receive the following exception error message:
System.ArgumentException: '0' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum'.
Note Not all circumstances that produce this error are known.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

RESOLUTION

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next .NET Framework 1.0 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.
The English version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date         Time   Version       Size       File name                 Platform
   -------------------------------------------------------------------------------
   03-Sep-2003  14:00  1.0.3705.454  1,179,648  System.data.dll           x86
   03-Sep-2003  14:01  1.0.3705.454  1,695,744  System.design.dll         x86
   03-Sep-2003  14:01  1.0.3705.454  1,994,752  System.windows.forms.dll  x86
   02-Sep-2003  23:06                   16,672  System.windows.forms.ldo
   02-Sep-2003  23:01  1.0.3705.454     57,344  System.windows.forms.tlb

MORE INFORMATION

Steps to Reproduce the Behavior

  1. In Microsoft Visual Studio .NET, create a new Visual Basic .NET Windows application. By default, Form1 is created.
  2. Add a Label control (Label1), a Command Button control (Command1), and a Panel control (Panel1) to Form1.
  3. Add a DataGrid control (DataGrid1) to the Panel control.
  4. Add the following code to Form1:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim i As Integer
            Dim ds As DataSet
            Dim myTable As DataTable
    
            Me.Panel1.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                Or System.Windows.Forms.AnchorStyles.Left) _
                Or System.Windows.Forms.AnchorStyles.Right)
            Me.Panel1.Location = New System.Drawing.Point(8, 48)
    
            ' Use the following MakeTable function to create a new table.
            myTable = MakeNamesTable()
    
            For i = 1 To 1000
                ds = New DataSet()
                ds.Tables.Add(myTable)
                DataGrid1.DataSource = ds.Tables(0).DefaultView
                Application.DoEvents()
                Label1.Text = (CStr(i) & " / 1000")
                DataGrid1.Width = (Panel1.Left + Panel1.Width) - 20
                ds.Tables.Remove(myTable)
            Next i
            MsgBox("Finished processing.  You must minimize the form before this point.")
            ds.Dispose()
        End Sub
    
        Private Function MakeNamesTable() As DataTable
            'Create a DataTable and add two columns to it.
            Dim namesTable As DataTable = New DataTable("Names")
            Dim fNameColumn As DataColumn = New DataColumn()
            Dim lNameColumn As DataColumn = New DataColumn()
            fNameColumn.DataType = System.Type.GetType("System.String")
            fNameColumn.ColumnName = "Fname"
            'fNameColumn.DefaultValue = "Fname"
            namesTable.Columns.Add(fNameColumn)
            lNameColumn.DataType = System.Type.GetType("System.String")
            lNameColumn.ColumnName = "LName"
            namesTable.Columns.Add(lNameColumn)
    
            'Add a row to the table.
            Dim myRow As DataRow
            myRow = namesTable.NewRow()
            myRow("fName") = "John"
            myRow("lName") = "Smith"
            namesTable.Rows.Add(myRow)
    
            ' Return the new DataTable.
            MakeNamesTable = namesTable
        End Function
  5. Run the application, and then click Button1. While the process is running, click the Minimize button that appears in the control box to minimize the form.

Modification Type:MinorLast Reviewed:10/25/2005
Keywords:kbHotfixServer kbQFE kberrmsg kbNetFrame100preSP3fix kbQFE kbfix kbBug KB828347 kbAudDeveloper