How Can I Find Out Who Is Passing a Wrong Parameter Value?

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic does not applyTopic does not apply

Native only

Topic does not apply

Standard

Topic does not applyTopic does not apply

Native only

Topic does not apply

Pro and Team

Topic does not applyTopic does not apply

Native only

Topic does not apply

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

The wrong parameter value is being passed to one of my functions. This function is called from all over the place. How can I find out what is passing it the wrong value?

To resolve this problem

  1. Set a location breakpoint at the beginning of the function.

  2. Right-click the breakpoint and select Condition.

  3. In the Breakpoint Condition dialog box, click on the Condition check box. For more information see How to: Specify a Breakpoint Condition.

  4. Enter an expression, such as Var==3, into the text box, where Var is the name of the parameter that contains the bad value, and 3 is the bad value passed to it.

  5. Select the is True radio button, and click the OK button.

  6. Now run the program again. The breakpoint causes the program to halt at the beginning of the function when the Var parameter has the value 3.

  7. Use the Call Stack window to find the calling function and navigate to its source code. For more information, see How to: Use the Call Stack Window.

Community Additions

ADD
Show: