Share via


Troubleshooting Exceptions: System.ArgumentOutOfRangeException 

An ArgumentOutOfRangeException is thrown when a method is invoked and at least one of the arguments passed to the method is not a null reference (Nothing in Visual Basic) and does not contain a valid value.

Associated Tips

  • Make sure all arguments to this method have valid values as defined by the invoked method.
    Arguments that are not null references must contain valid values.
  • If you are working with a collection, make sure the index is less than the size of the collection.
    The index must be within the size range of the collection and cannot exceed the size range or be less than zero.

  • When using the overloaded two-argument FindString or FindStringExact methods of the ComboBox or ListBox class, check the startIndex parameter.
    This exception may be thrown if startIndex is equal to the index value of the last item of the associated list. To work around this, pass 0 as the startIndex parameter or use the one-argument FindString or FindStringExact method. For more information, see CComboBox::FindString or CListBox::FindString.

See Also

Tasks

How to: Find Out More About an Exception with the Exception Assistant

Reference

Visual J# Exception Handling for the Debugger
Visual J# Exception Hierarchies
ArgumentOutOfRangeException