1 <Type Name="InvalidOperationException" FullName="System.InvalidOperationException" FullNameSP="System_InvalidOperationException" Maintainer="ecma">
2 <TypeSignature Language="ILASM" Value=".class public serializable InvalidOperationException extends System.SystemException" />
3 <TypeSignature Language="C#" Value="public class InvalidOperationException : SystemException" />
4 <MemberOfLibrary>BCL</MemberOfLibrary>
6 <AssemblyName>mscorlib</AssemblyName>
7 <AssemblyPublicKey>[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]</AssemblyPublicKey>
8 <AssemblyVersion>1.0.5000.0</AssemblyVersion>
9 <AssemblyVersion>2.0.0.0</AssemblyVersion>
10 <AssemblyVersion>4.0.0.0</AssemblyVersion>
12 <ThreadingSafetyStatement>All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.</ThreadingSafetyStatement>
14 <BaseTypeName>System.SystemException</BaseTypeName>
19 <para> Represents the error that occurs when an operation cannot be
23 <block subset="none" type="note">
25 <see cref="T:System.InvalidOperationException" /> is typically thrown when the state of
26 one or more objects determines whether an operation can be performed.</para>
27 <para>The <see cref="T:System.InvalidOperationException" /> exception should not be thrown for
28 errors caused by invalid arguments. For invalid argument errors, throw <see cref="T:System.ArgumentException" /> or one
29 of its derived types, such as <see cref="T:System.ArgumentNullException" /> or <see cref="T:System.ArgumentOutOfRangeException" />. </para>
30 <para> The ldflda CIL instruction throws <see cref="T:System.InvalidOperationException" />. </para>
34 <para>The following example demonstrates an error that causes
35 a <see cref="T:System.InvalidOperationException" /> exception.</para>
36 <code lang="C#">using System;
37 using System.Collections;
38 public class InvalidOpExample {
39 public static void Main() {
41 IEnumerator enumerator = array.GetEnumerator();
42 Console.Write("{0}",enumerator.Current);
46 <para>The output is</para>
48 <para>Unhandled Exception: System.InvalidOperationException: Enumeration has not
49 started. Call MoveNext.</para>
50 <para>at System.SZArrayEnumerator.get_Current()</para>
51 <para>at InvalidOpExample.Main()</para>
56 <Member MemberName=".ctor">
57 <MemberSignature Language="ILASM" Value="public rtspecialname specialname instance void .ctor()" />
58 <MemberSignature Language="C#" Value="public InvalidOperationException ();" />
59 <MemberType>Constructor</MemberType>
64 <para>Constructs and initializes a new instance of the <see cref="T:System.InvalidOperationException" />
68 <para>This constructor initializes the <see cref="!:System.InvalidOperationException.Message" /> property of the new instance to a system-supplied
69 message that describes the error, such as "The requested operation cannot be
70 performed." This message takes into account the current system culture.</para>
71 <para>The <see cref="!:System.InvalidOperationException.InnerException" /> property is initialized to
72 <see langword="null" />.</para>
75 <Excluded>0</Excluded>
77 <AssemblyVersion>1.0.5000.0</AssemblyVersion>
78 <AssemblyVersion>2.0.0.0</AssemblyVersion>
79 <AssemblyVersion>4.0.0.0</AssemblyVersion>
82 <Member MemberName=".ctor">
83 <MemberSignature Language="ILASM" Value="public rtspecialname specialname instance void .ctor(string message)" />
84 <MemberSignature Language="C#" Value="public InvalidOperationException (string message);" />
85 <MemberType>Constructor</MemberType>
88 <Parameter Name="message" Type="System.String" />
91 <param name="message">A <see cref="T:System.String" /> that describes the error. The content of <paramref name="message" /> is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.</param>
93 <para>Constructs and initializes a new instance of the <see cref="T:System.InvalidOperationException" />
97 <para>This constructor initializes the <see cref="!:System.InvalidOperationException.Message" /> property of the new instance using <paramref name="message" />. If <paramref name="message" /> is
98 <see langword="null" />, the <see cref="!:System.InvalidOperationException.Message" /> property is initialized to a system-supplied message. The <see cref="!:System.InvalidOperationException.InnerException" /> property is initialized to <see langword="null" />.</para>
101 <Excluded>0</Excluded>
103 <AssemblyVersion>1.0.5000.0</AssemblyVersion>
104 <AssemblyVersion>2.0.0.0</AssemblyVersion>
105 <AssemblyVersion>4.0.0.0</AssemblyVersion>
108 <Member MemberName=".ctor">
109 <MemberSignature Language="C#" Value="protected InvalidOperationException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);" />
110 <MemberType>Constructor</MemberType>
112 <Parameter Name="info" Type="System.Runtime.Serialization.SerializationInfo" />
113 <Parameter Name="context" Type="System.Runtime.Serialization.StreamingContext" />
116 <param name="info">To be added.</param>
117 <param name="context">To be added.</param>
118 <summary>To be added.</summary>
119 <remarks>To be added.</remarks>
122 <AssemblyVersion>1.0.5000.0</AssemblyVersion>
123 <AssemblyVersion>2.0.0.0</AssemblyVersion>
124 <AssemblyVersion>4.0.0.0</AssemblyVersion>
127 <Member MemberName=".ctor">
128 <MemberSignature Language="ILASM" Value="public rtspecialname specialname instance void .ctor(string message, class System.Exception innerException)" />
129 <MemberSignature Language="C#" Value="public InvalidOperationException (string message, Exception innerException);" />
130 <MemberType>Constructor</MemberType>
133 <Parameter Name="message" Type="System.String" />
134 <Parameter Name="innerException" Type="System.Exception" />
137 <param name="message">A <see cref="T:System.String" /> that describes the error. The content of <paramref name="message" /> is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.</param>
138 <param name="innerException">An instance of <see cref="T:System.Exception" /> that is the cause of the current Exception. If <paramref name="innerException" /> is non-null, then the current Exception was raised in a catch block handling <paramref name="innerException" /> .</param>
140 <para>Constructs and initializes a new instance of the <see cref="T:System.InvalidOperationException" />
144 <para>This constructor initializes the <see cref="!:System.InvalidOperationException.Message" /> property of the new instance using <paramref name="message" />, and
145 the <see cref="!:System.InvalidOperationException.InnerException" /> property using
146 <paramref name="innerException" />. If <paramref name="message" /> is
147 <see langword="null" />, the <see cref="!:System.InvalidOperationException.Message" /> property is initialized to a system-supplied message.</para>
149 <block subset="none" type="note">For information on
150 inner exceptions, see <see cref="P:System.Exception.InnerException" />
155 <Excluded>0</Excluded>
157 <AssemblyVersion>1.0.5000.0</AssemblyVersion>
158 <AssemblyVersion>2.0.0.0</AssemblyVersion>
159 <AssemblyVersion>4.0.0.0</AssemblyVersion>
163 <TypeExcluded>0</TypeExcluded>
166 <AttributeName>System.Runtime.InteropServices.ComVisible(true)</AttributeName>