views:

263

answers:

2

Hi there.

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?

+2  A: 

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.

Gerrie Schenck
Break on exception might be the winner here, because you'll be able to look in the autos / locals window to see the control, datasource and data member
Rob Fonseca-Ensor
No inner exception or any useful infromation from the thrown ArgumentException. Breaking on all CLR exceptions is enabled, and it doesn't seem to change much.I'll try the 'Show External code' option if its not already on.So far, no luck.
Ran Sagy
A: 

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.

Ran Sagy