Question

I have a couple of massive data structures that are causing problems in my VB.NET application. After an exception is thrown and the application pauses, I'd like to run some code like:

For Each o As MyClass In myObjects
  If o.property = "value" Then debug.print(o.id)
Next

to diagnose the problem.

The problem is that the immediate window won't let me execute loops, and the myObjects collection contains far too many objects for me to find the offending one I want manually.

How can I find this object while the debugger is paused? Is this, or something similar, possible in the .NET IDE?

Was it helpful?

Solution

You should be able to use the Immediate mode window in the IDE to execute commands like that, but the data has to be available within the current scope of the debugger.

OTHER TIPS

No, you can't do this directly from the IDE. Unfortunately, the easiest way to work around it is to stop debugging, write your loop inside a public static method that returns the object you are looking for, re-compile and run, and then call that public static method from the Immediate or Watch window.

Another more immediate (but annoying) trick is to write "? myObjects" in the Immediate window, copy paste the result into notepad, and use text search (Ctrl+F) in notepad to find your object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top