使用 MVVM Foundation Messenger 时如何使 Visual Studio 调试器更有用?
我总体上对 MVVM Foundation Messenger 非常满意,但我注意到,当 Messenger 调用导致异常时,Visual Studio 调试器似乎不会将我带到导致异常的代码行(而是,它跳转到调用该操作的 Messenger
类中的方法)。这迫使我进行大量的搜索来找到有问题的代码行。 (注意:我认为这都是 Messenger 使用弱引用的副作用,否则这是一件好事。)
问题:
在使用 Messenger 时,有什么可以改善调试体验吗?信使?
Visual Studio 中是否有某些设置或命令可以让我直接跳转到导致异常的代码行?
至少,您能否提出一些有用的策略来快速隔离异常原因?
(注:我使用的是 Visual Studio 2008)
I've been generally very pleased with the MVVM Foundation Messenger, but I've noticed that when a messenger call causes an exception, the Visual Studio debugger doesn't ever seem to take me to the line of code that caused the exception (instead, it jumps to the method in the Messenger
class that invoked the action). This forces me to do a lot of hunting around to find the offending line of code. (Note: I figure this is all a side effect of the Messenger using weak references, which is otherwise a good thing.)
Questions:
Is there anything that can be done to improve the debugging experience when using the messenger?
Is there some setting or command in Visual Studio that would let me jump directly to the line of code that caused the exception?
At the very least, can you suggest helpful strategies for quickly isolating the cause of the exception?
(Note: I'm using Visual Studio 2008)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为调试任何 WPF 绑定问题(尤其是 MVVM)的最佳方法是将转换器分配给正在绑定的组件。
这样您就知道绑定是否(以及可能何时)发生。当然,这种方法对于使用信使也可能有效。
使用转换器的快速链接:
I think the best way to debug any WPF binding issues (especially regards MVVM), is to assign a Convertor to the component that is being binded.
This way you know if (and possibly when) the binding takes place. Of course this method might be effective using the messenger as well.
A quick link for using the convertor:
http://www.codeproject.com/KB/WPF/debugwpfdatabinding.aspx