Setting your sights low
I reported the Winforms Designer issue as a bug on Microsoft Connect. They swiftly marked it resolved “by design.”
What’s by design, exactly? Here are the actual and expected results from my bug report:
Actual Results
A dialog box saying “Specified cast is not valid” with an OK button, displayed three times, and then information lost about control instances within the form.
Expected Results
A clear, specific indication of the invalid typecast problem encountered while saving the form. And minimal information loss when the form is saved anyway.
So it is “by design” that instead of a clear, specific indication of the problem, we get a dialog box with only the exception message, and not even a mention that this message is coming from our own code? Just a quick and cheap MessageBox.Show(ex.Message) and their work is done?
Here is Microsoft’s exact response:
I’m afraid this is largely a byproduct of the way in which the windows forms designer works. It is setting the properties on a live object. If this object throws an exception, the designer has the choice of either letting the object throw (which would crash Visual Studio) or catching the exception. When it catches the exception, it displays the Message from the exception. The message you’re describing is the typical one for invalid cast. Hooking up a debugger will find what line the exception happens on, which would make it easy to see what the exact issue is (not just type information, but values, state, etc.)
UIFX Team
This misses the point completely.
I know full well that the designer works on live objects, and that bugs in controls therefore must cause problems. My complaint is about how those problems are handled, not that they come up. What’s “by design” is that they come up, sure. How they are handled is not “by design” (we should hope!) — it is a real usability issue that remains to be resolved. But Microsoft just shrugs it off, “you can attach a debugger to help find it.”
My point is that the exception they catch contains valuable information about the problem (the stack trace), and they do not give it to us.
Should we be grateful that at least we get a line number on compiler errors, without having to attach a debugger?
This product desperately needs competition.