Last week I spent quite a lot of time tracking down this bug I found in Visual Studio .NET and thought I would share it in case anyone else bumps into the same problem. I opened up our WinForms application and was just about to configure databinding for a control by going to the
Properties window ->
Databindings.
If I pressed the drop down arrow for a property where you normally get something like this:
I would get this instead:
And if I went to the
Advanced options and pressed the
Bindings drop down, the dialog box would simply crash.
The first thing I did was to double check that all the datasources for the User Control I was working on where all correct. They were. But after a while I realised that the problem did not occur only with my newly added User Control, it was a general problem with all User Controls and Forms in my entire project.
After a couple of hours looking through change sets and past versions of our project, I found that the problem had appeared after a simple renaming of one of our BusinessEntities used for databinding. The problem was of course the fact that after the renaming the datasource had not been updated. This is illustrated in the rather lame example I have used for this post below (
Class3 renamed to
Class2):
In our WinForms application the list of datasources was a lot longer, and it was therefore much more difficult to track down the problem.
I think it is rather unfortunate that such a powerful tool for designing applications exhibits such weak error handling in a world where refactoring (simple renaming in this example) is so necessary to make code more readable and maintainable.
Solution
The solution is simply to delete the old datasource and add it again.