Freigeben über


Using IntelliTrace to view the return value of a VB or C# method

A few months ago, I blogged about how to view the return value of a C# or VB method in the Visual Studio debugger. As I explained in that blog post, the debugger does not support viewing the return value of a .NET method, so you have to apply a workaround or two.

Being able to see the return value of a method comes in particularly handy when you have methods that take other methods as their parameters, e.g. F(A(x), B(y)), where A() and B() are methods themselves. For example, in the code example below, how can you see the value that is returned by c.CalculateArea(radius)?

Return Value

IntelliTrace in Visual Studio 2010 makes it easy to view the return value of a method.

The first step is to change the default IntelliTrace options to record "events and call information", as shown below.

IntelliTrace Options

After enabling the above option, IntelliTrace will record the return value and parameters of all methods in the running application. Now, whenever you stop in the debugger, the IntelliTrace NavBar is displayed in the editor margin. To see the return value of a method, click the "Go to Previous Event" button (Ctrl+Shift+F11) to step back to the method that you want to see the value for, shown below.

IntelliTrace NavBar

After clicking the button, the debugger will display the method that you stepped back to in the Autos window, as shown in the following screenshot.

Debugger Autos window

Expanding the method in the Autos window will display the return value. The debugger displays the name of the return value as [Return Value] .

Return Value in Autos window 

Habib Heydarian.