简体   繁体   English

使用INotifyPropertyChanged在Visual Studio 2008中调试属性设置

[英]Debugging Property Settings in Visual Studio 2008 with INotifyPropertyChanged

I have a class with a property that gets set by another class. 我有一类具有由另一个类设置的属性。 Inside this property setter the program blows up. 在此属性设置器中,程序会崩溃。

I just need to know what class actually set the property. 我只需要知道实际上哪个类设置了属性。

I thought I could just look at the stacktrace, but because I am using INotifyPropertyChanged I think it doesn't give me the full information I am looking for. 我以为我可以看一下堆栈跟踪,但是因为我使用的是INotifyPropertyChanged,所以我认为它不能提供我所需要的全部信息。

Here is the stack trace if this helps: 如果有帮助,这是堆栈跟踪:

    MyProject!MyProject.MyClass.MyProperty.set(string value = "") Line 24   C#
[Native to Managed Transition]  
[Managed to Native Transition]  
System.Windows.dll!System.Windows.CLRPropertyListener.Value.set(object value = "") + 0x58 bytes 
System.Windows.dll!System.Windows.PropertyAccessPathStep.Value.set(object value = "") + 0x28 bytes  
System.Windows.dll!System.Windows.PropertyPathListener.LeafValue.set(object value = "") + 0x28 bytes    
System.Windows.dll!System.Windows.Data.BindingExpression.UpdateValue() + 0x26c bytes    

System.Windows.dll!System.Windows.Data.BindingExpression.TargetTextBoxLostFocus(object sender = {System.Windows.Controls.TextBox}, System.Windows.RoutedEventArgs e = {System.Windows.RoutedEventArgs}) + 0x55 bytes System.Windows.dll!System.Windows.Data.BindingExpression.TargetTextBoxLostFocus(对象发送者= {System.Windows.Controls.TextBox},System.Windows.RoutedEventArgs e = {System.Windows.RoutedEventArgs})+ 0x55字节
System.Windows.dll!System.Windows.CoreInvokeHandler.InvokeEventHandler(int typeIndex = 160, System.Delegate handlerDelegate = {System.Windows.RoutedEventHandler}, object sender = {System.Windows.Controls.TextBox}, object args = {System.Windows.RoutedEventArgs}) + 0x6b3 bytes System.Windows.dll!MS.Internal.JoltHelper.FireEvent(System.IntPtr unmanagedObj = 173934552, System.IntPtr unmanagedObjArgs = 273432032, int argsTypeIndex = 160, string eventName = "M@2910") + 0x335 bytes System.Windows.dll!System.Windows.CoreInvokeHandler.InvokeEventHandler(int typeIndex = 160,System.Delegate handlerDelegate = {System.Windows.RoutedEventHandler},对象发送者= {System.Windows.Controls.TextBox},对象args = {System .Windows.RoutedEventArgs})+ 0x6b3字节System.Windows.dll!MS.Internal.JoltHelper.FireEvent(System.IntPtr unmanagedObj = 173934552,System.IntPtr unmanagedObjArgs = 273432032,int argsTypeIndex = 160,字符串eventName =“ M @ 2910” )+ 0x335字节

Hmm. 嗯。 . .

You can break point in your property setter and use Call Stack window to trace which one called it. 您可以在属性设置器中断点,并使用“调用堆栈”窗口来跟踪哪个调用它。

It's a little old school, but have you tried adding Debug.WriteLine() statements to trace your program execution? 它有点老了,但是您是否尝试过添加Debug.WriteLine()语句来跟踪程序执行? You can view the results of Debug.WriteLine() in the VS Output window while your program runs. 程序运行时,可以在“ VS输出”窗口中查看Debug.WriteLine()的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM