【Winform】 无法将类型为“System.Windows.Forms.SplitContainer”的对象强制转换为类型“System.ComponentModel.ISupportInitialize”。

问题:将dotnet framework 4.0 切换到2.0时,编译没有问题,在运行时出现如下错误:System.InvalidCastException: 无法将类型为“System.Windows.Forms.SplitContainer”的对象强制转换为类型“System.ComponentModel.ISupportInitialize”。

解决方法:

注释掉如下代码(此代码为设计器自动生成代码)

 

//((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
  //((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();

 

【参考文献】点击进入

 

posted @ 2015-03-28 12:02  芝麻学问  阅读(2267)  评论(0编辑  收藏  举报