Debugging data bindings in Winforms C #?

Recently, I get a lot of problems in a project in which I work with data binding. When im is about to display a specific form that has bindings inside its controls, the .Show method generates calculations with respect to the binding - "You cannot bind to a property or column in a data source. Parameter name: dataMember.".

Now I fully understand that this is a pretty general error message, but I canโ€™t find a decent way to get information about which binding failed, which control, which source / data member, etc.

Is there a good way to find this?

+4
source share
2 answers

I think some general debugging tips will help:

When debugging, is there an internal exception with additional information?

Another tip is to enable Show External Code in the stack trace window. This will allow you to move further on the stack to the .Net Framework itself. Turn on the locales window to get information about the contents of the current context, this can lead to a problem.

Also be sure to enable โ€œBreak on exceptionโ€ for all CLR exceptions.

Good luck.

+2
source

OK, I'm at a standstill. One of the controls on the form is UserControl i, which contains some bindings in it.

This worked fine. Now I have added the inhertience property of IEnumerable to my control so that it can return specific objects inside it for another function that I was trying to add. Now, if I 'Step-Into' calls .Show, I achieve the IEnumrable implementation made in a specific case.

Although at this time, he returned an empty collection, since I did not have items to return. Apparently, for some reason, it raised an ArgumentException, which I got with a DataBinding. The moment I remove IEnumrable inheritance from my control, everything returns to normal.

I absolutely do not know why this happened.

+1
source

All Articles