質問

In Visual Studio I would like to keep an eye on the state of a particular .NET object. The object starts out referenced by a local variable and I would like to continue watching the object in other stack frames or even other threads. Even if the local variable is set to null, I want to keep watching the original object. Is this possible?

役に立ちましたか?

解決

You can right-click on the object in the debugger (either on the "popup" when you hover the mouse somewhere, or in the Watch Window) and invoke the "Make Object ID" command. That assigns an ID to the object that you can reference with 1# (or whatever the ID is) in the Watch Window or the Immediate Window.

This ID is a string reference to the object. It never goes away as long as the debugger is attached.

You can even use this pound syntax is in the pseudo-C# language that the Watch and Immediate Windows support (e.g. 1#.SomeProperty).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top