3

I need help with an annoying bug that I can't seem to overcome.

In my work I have a large WPF/C# program and sometimes when you login there is an exception thrown, a null reference exception at System.Windows.Data.BindingExpression.IsValidValueForUpdate.

The exception is only caught in the app.xaml.cs as a DispatcherUnhandledExceptionEventArgs and when I look at the data of the exception it contains a key that is an object (not specific object) and the value of the key is null.

How do I even start and find the problem? I read online multiple things and I put some code in comment but still can't find what is wrong. If anyone has advice how to debug this kind of problem it would be much appreciated. Thanks in advance

fejese
  • 4,601
  • 4
  • 29
  • 36
user3260639
  • 158
  • 1
  • 14
  • 1
    For me this is not well asked question. Not only wall of text, but no code, no exception, improve your question or probably nobody will answer you. Good luck – mybirthname Nov 02 '14 at 14:04
  • It's a big solution I have no specific code to post. If I had I would have known where the problem was at. I am not looking for someone to tell me how to solve this but how to find where the problem is at. – user3260639 Nov 02 '14 at 14:08
  • 1
    Can you replicate the problem while debugging? You could look at the call stack to try and track down where the problem originates. – Chris Nov 02 '14 at 14:25
  • Yeah, I tried that but there is no real call stack. The call stack displays methods in the System.Windows.Data Bindingexpression class – user3260639 Nov 02 '14 at 14:29
  • 2
    If you can reproduce it while debugging that try to look in internal exception and then stack trace. If at all you cannot get it then you know its login page, should not be that big so try to put dummy value converters for bindings and debug you will get hold of it – Bhupendra Nov 02 '14 at 15:10
  • 2
    Potentially try increasing the level of detail of your wpf trace: http://msdn.microsoft.com/en-gb/library/dd409960.aspx otherwise, as @whoisthis says, start stubbing out various bindings until you find the one that's causing you grief. – Chris Nov 02 '14 at 15:11
  • Thanks! I'll try what you both said – user3260639 Nov 02 '14 at 15:44

1 Answers1

3

For anyone who comes across this problem, I fixed in my project. In one of the xamls there was a binding with a OnwWayToSource mode and a converter. The link below has an answer by a user that figured this out. (WPF) Binding OneWayToSource with a converter results in immediate exception

Apparently a binding with a OnwWayToSource and converter throws this exception and the work around is to give a data context. The solution I did was that I saw that the code can have a TwoWay mode in the Convert function of the converter just write "return value;"

Community
  • 1
  • 1
user3260639
  • 158
  • 1
  • 14