1

在 Visual Studio 2010 中调试时,有没有办法在 QuickWatch 窗口中查看 HttpSessionState 的键?

必须有更好的方法,然后退出调试会话,在 Session.Contents.Keys 对象上编写循环,设置断点,然后单步执行循环 - 只是为了查看定义了哪些键。

我怀疑我正在以完全不正确的方式处理这个问题。提示或建议将不胜感激。

4

1 回答 1

2

HttpSessionState is an IEnumerable, so as long as System.Core DLL is loaded in the process you're debugging, you can just evaluate System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Cast<object>(myHttpSessionState)) in the QuickWatch window. If the current code file has a using System.Linq statement, you can write a shorter expression: myHttpSessionState.Cast<object>().ToArray()

If you're having to look at HttpSessionState objects often, you may want to try BugAid, and define the above expression as a Custom Expression on the HttpSessionState class, so you won't be forced to type in the long expression each and every time.

Full Disclosure: I'm the co-creator of BugAid.

于 2012-06-05T09:36:44.587 回答