This documentation is archived and is not being maintained.

Troubleshooting Exceptions: System.InvalidOperationException 

An InvalidOperationException exception is thrown in cases when the failure to invoke a method is caused by a reason other than an invalid argument. This may be thrown by .NET Framework methods when the underlying Win32 method cannot be invoked.

If you are using the Graphics object after the GetHdc method, call the ReleaseHdc method.

This will release the context handle obtained by a previous call to the GetHdc method of the Graphics object.

TableAdapters require valid UPDATE, INSERT, and DELETE commands to perform a successful save operation.

TableAdapters generate INSERT, UPDATE, and DELETE statements based on the original SELECT statement entered into the wizard. In some situations, the SELECT statement does not provide enough information for the adapter to generate the commands necessary to create the INSERT, UPDATE, and DELETE commands required for a successful save. This often occurs when the database table does not have a primary key column, or the SELECT command uses JOINS. For more information, see How to: Edit TableAdapters.

When you run your code in the Visual Studio debugger, an InvalidOperationException is thrown if you access a UI element from any thread other than the one on which it was created. The debugger does this to alert you to a dangerous programming practice. UI elements are not thread-safe and should be accessed only on the thread that created them. For more information, see Multithreading in Visual Basic.

If the method invocation failure is due to an invalid argument or arguments, then ArgumentException or one of its derived classes, ArgumentNullException or ArgumentOutOfRangeException exception, should be thrown instead.