Today I had a strange problem with VSTS 8.0.50727.42: I could not add a new data source of type 'object' to my Windows control library project. Adding a database or web-service data source worked fine.
The wizard would crash when trying to open the 'Select the object you wish to bind to' page of the wizard. The error message was this:
An unexpected error has occured.
Error message: Object reference not set to an instance of an object.
If I made a new Windows control library project and added classes from my business entity assembly as object data sources, the wizard worked as expected (kind of stupid that several classes cannot be added in one go, though). After several hours of experimenting with project references, structure, and even names, I finally saw the pattern of when the wizard worked and when it crashed. The wizard is dependent on your project having at least one public class in the root folder of your project.
In my Windows control library project I have structured the source code into several folders with no classes in the root. VS by default generates a class called 'UserControl1' in the root, and if you delete this class, the wizard will fail.
I now use a dummy class 'XDummyClassForDataBinding' in my project.
14 comments:
Thanks for the investigative work. I was having the same problem and was about to chuck this @#$%^& machine out the window. Me and my blood pressure thank you.
Thanks for posting this. It is unimaginable that we have to work with this level of technology today. I waste so much time trying to figure out how to get around bugs left in a system by MS.
Schweet!! You're right. This has fixed my problem. I didn't spot the pattern initially - it seemed sporadic and i initially fixed it by creating a new project, but it later stopped working when I removed the default class from the root.
Good stuff! Everything all fell over when I tidied my code into directories - I dont think I would have come up with that fix on my own. Cheers heaps - Nick Hoggard
You saved the day. Stupid stuff like this wastes so many days worth of troubleshooting on a project. Thanks for the post!
Its almost a year later, and you saved my butt!!!
Thanks
Thank you so very much. Your answer was concise and on point! I'm just starting with VS2005 and so all explanations are a blessing at this point.
Thanks again.
Great, very usefull tip!
Hallo old collegue, I rembered you solved this problem on a common project once upon a time. I googled, and found your post and solution. Thanx.
VS sometimes is very dumb... Thx.
You're brilliant, VB is poo! Been told I've got to do the project in VB, not C# and this is just another thing that convinces me I should stick to C#.
Works like a charm.
All I have to say to Micro$oft is:
WHY?
Thanks for posting this! Brilliant investigation work.
Post a Comment