简体   繁体   中英

Debugging Data Binding in Winforms C#?

I'm getting alot of issues lately in a project im working on with databinding. When im about to display a certain form that has bindings inside its controls, the .Show method throws expcetions regarding the binding - "Cannot bind to property or column on datasource. Parameter name: dataMember.".

Now, I'm quite aware this is a rather generic error message, but i can't find a decent way to get any info on which binding failed, which control, which data source/member and so on.

Is there a good way to find this?

I guess some general debugging tips will help:

When debugging, is there an inner exception with more information?

Another tip is to turn on 'Show external code' in the stack trace window. This will allow you to go further down into the stack to the .Net Framework code itself. Turn on your locals window for information on the content of the current context, this might lead you to the problem.

Also be sure to turn on 'Break on exception' for all CLR exceptions.

Good luck.

Well, I'm stumped. One of the controls in the form is a UserControl i made, Which contains some bindings in it.

This used to work fine. Now, I've added inhertience from IEnumerable to my control so it can return certain objects inside it for a different feature i tried adding. Now, If i 'Step-Into' the .Show call, I reach the IEnumrable implementation i made in a certain case.

Although it returned an empty collection at this time, since i had no elements to return, That apparently caused the ArgumentException that i got with the DataBinding for some reason. The moment i remove the IEnumrable inheritence from my control, Everything is back to normal.

I'm completely clueless as to why this happened.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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