Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know details of System.InvalidOperationException in System.Windows.Forms.dll?

Tags:

c#

.net

exception

When running my application, I found exception log below in Output panel of Visual Studio.

A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll

This application's architect is as follows.

  • Second thread: Enqueue "add item to listview" or "change item to listview" command into a queue.
  • Main thread: Dequeue from a queue and execute add or change operation defined by each command.

I want to know details of InvalidOperationException called from, but it's only shown on Output panel, so I can't catch it for viewing stack trace. Is there a way to know it?

like image 918
kobake Avatar asked Jul 02 '13 17:07

kobake


People also ask

What does InvalidOperationException mean?

InvalidOperationException is used in cases when the failure to invoke a method is caused by reasons other than invalid arguments. Typically, it is thrown when the state of an object cannot support the method call. For example, an InvalidOperationException exception is thrown by methods such as: IEnumerator.

Where is the system Windows Form DLL?

Windows. Forms. dll is located in the folder C:\WINDOWS\Microsoft.NET\Framework\v2.

How do I add a system window form in Visual Studio?

Add a new form In Visual Studio, find the Project Explorer pane. Right-click on the project and choose Add > Form (Windows Forms).


1 Answers

The best way to find where an exception like this is being triggered is to set the debugger to break on all exceptions.

You can do this by going to the Exception Settings window and checking the checkbox next to Common Language Runtime Exceptions under 'Break When Thrown'.

If you don't see the Exception Settings window, you can open it from the top menu at Debug -> Windows -> Exception Settings (there's also a keyboard shortcut of Ctrl+Alt+E to open it.

This will break anytime a .NET exception is thrown, regardless of where or whether it's handled.

This won't fix your problem, but it'll help identify it.

like image 137
Bobson Avatar answered Sep 21 '22 15:09

Bobson