views:

525

answers:

2

I recently got tossed some C# code to make some minor cosmetic changes to. When I open up some of the files in VisualStudio though, I get errors saying "To prevent possible data loss..."

The first of these errors is "Object reference not set to an instance of an object. "

I can follow the stack trace fine, but I'm not sure what I really should be looking for in this situation.

Also, the end of my stack trace has a call that ends in "PageScroller..ctor() "

Based on a little Google research, I'm assuming that means call the constructor, but I wanted to verify.

+1  A: 

You have a bug in design mode for some custom control, probably PageScroller, and apparently starting from the constructor. Perhaps there's some code in the constructor that returns null in design mode, and the null is not checked for.

John Saunders
Is it common (or at least acceptable) in the C# world to have a number of pages where they work fine but they are not viewable in the designer? It seems most of the page I'm looking at do function, just don't show up in the designer. Overall, that would make it easier for me to fix things so I don't have to learn the designer interface, but I wanted to know if that would be considered "bad practice"
Kivus
No, it's not acceptable, at least not to me. It's not necessary for every control to have extensive Designer support, but it should be possible to at least _open_ the page in the designer, set properties, and save the page, and have the properties persist.
John Saunders
Excellent. Thank you for the help.
Kivus
A: 

I occasionally see problems like this. I started moving code from the constructor to the load event and that helped.

jon37