Change the value of a local
Applies to: Visual Studio Visual Studio for Mac
Note
This article applies to Visual Studio 2017. 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:
After the user enters the new value, Visual Studio calls SetValueAsString on the IDebugProperty2 object associated with the local.
IDebugProperty2::SetValueAsString
performs the following tasks:Evaluates the string to produce a value.
Binds the associated IDebugField object to obtain an IDebugObject object.
Converts the value to a series of bytes.
Calls SetValue to put the value's bytes into memory so the program being debugged can access them.
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 theIDebugProperty2
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.