Fun and games with Visual Studio 2010 beta 2
Well, Houston, it seems we have a problem. The majority — if not all — of our WinForms controls will not work in VS2010 beta 2. To be blunt, there seems to be some serious design flaws.
The problem is that VS2010 beta 2 doesn’t generate any code for the ISupportInitialize
interface when you drop controls on a form. In particular, it must generate calls to the BeginInit
and EndInit
methods of that interface inside InitializeComponent()
.
Here's an example from VS2008:
private void InitializeComponent() { this.dataGridView1 = new System.Windows.Forms.DataGridView(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); // <<*** this.SuspendLayout(); // other code dealing with dataGridView1 ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); // <<*** this.ResumeLayout(false); ... }
But, with VS2010 we get this:
private void InitializeComponent() { this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.SuspendLayout(); // other code dealing with dataGridView1 this.ResumeLayout(false); ... }
Note how the two marked statements from the VS2008 example have disappeared with VS2010 beta 2. Also note that you don't have to use a third-party control, like ours, you can just use the standard DataGridView control to see the problem.
In essence, our WinForms controls can’t (and won't) work properly when the calls to BeginInit
/EndInit
are not generated at design-time by the IDE like this. There is nothing we can do either: this generated code creates the controls on the form and, by the time our run-time code gets hold of the form, it's way too late (if an exception hasn't already been thrown, of course).
This issue has already been reported by others to Microsoft. Here's an example: http://beta.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=499882
So, enjoy your testing of VS2010 beta 2. We'll be seeing you the other side.