|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
Troubleshooting Exceptions: System.InvalidOperationException
Anexception 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 themethod of the 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.
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.
If the method invocation failure is due to an invalid argument or arguments, thenor one of its derived classes, or exception, should be thrown instead.