Changing the Value of a Local

When a new value is typed in the value field of the Locals window, the debug package passes the string, as typed, to the expression evaluator (EE). The EE evaluates this string, which can contain either a simple value or an expression, and stores the resulting value in the associated local.

This is an overview of the process of changing the value of a local:

  1. After the user enters the new value, Visual Studio calls IDebugProperty2::SetValueAsString on the IDebugProperty2 object associated with the local.

  2. IDebugProperty2::SetValueAsString performs the following tasks:

    1. Evaluates the string to produce a value.

    2. Binds the associated IDebugField object to obtain an IDebugObject object.

    3. Converts the value to a series of bytes.

    4. Calls IDebugObject::SetValue to put the value's bytes into memory so the program being debugged can access them.

  3. Visual Studio refreshes the Locals display (see Displaying Locals for details).

This procedure is also used to change the value of a variable in the Watch window except it is the IDebugProperty2 object associated with the value of the local that is used instead of the IDebugProperty2 object associated with the local itself.

In This Section

See Also

Other Resources

Writing a Common Language Runtime Expression Evaluator

Displaying Locals