Mono Class Library: System NamespaceSystem.InvalidOperationException Class |
See Also: InvalidOperationException Members
System.Object
System.Exception
System.SystemException
System.InvalidOperationException
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
Note:[Edit]InvalidOperationException is typically thrown when the state of one or more objects determines whether an operation can be performed.
The InvalidOperationException exception should not be thrown for errors caused by invalid arguments. For invalid argument errors, throw ArgumentException or one of its derived types, such as ArgumentNullException or ArgumentOutOfRangeException.
The ldflda CIL instruction throws InvalidOperationException.
The following example demonstrates an error that causes a InvalidOperationException exception.
C# Example using System; using System.Collections; public class InvalidOpExample { public static void Main() { int[] array = {0,0}; IEnumerator enumerator = array.GetEnumerator(); Console.Write("{0}",enumerator.Current); } }The output is
Unhandled Exception: System.InvalidOperationException: Enumeration has not started. Call MoveNext.
at System.SZArrayEnumerator.get_Current()
at InvalidOpExample.Main()
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0