Home > View Post

Visual Studio .NET Datasources bug

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:

Object reference not set to an instance of an object.

And if I went to the Advanced options and pressed the Bindings drop down, the dialog box would simply crash.

Advanced databindings

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):

Renamed Business Entity

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.


The solution is simply to delete the old datasource and add it again.

Tags: WinForms.NET

Bruusi Post By Bruusi
5:37 AM
23 Jul 2006

» Next Post: PropertyListView control
« Previous Post: Get organised with Solution Folders

Comments are closed for this post.

Posted by KjellSJ @ 03 Aug 2006 12:05 AM
Hmm, have we been working on the same project for four months now ?!! =D

© 2005 - 2022 Josh Twist - All Rights Reserved.