Compartilhar via


Changing the Value of a Local

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Important

In Visual Studio 2015, this way of implementing expression evaluators is deprecated. For information about implementing CLR expression evaluators, please see CLR Expression Evaluators and Managed Expression Evaluator Sample.

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 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 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

Sample Implementation of Changing Values
Uses the MyCEE sample to step through the process of changing values.

See Also

Writing a CLR Expression Evaluator
Displaying Locals