【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();

【参考文献】点击进入

时间: 2024-08-09 23:56:15

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

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

解决办法: 在设计器代码中把4.0自动加上去的代码注释掉就行了. //((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();  //((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); 按不同的版本进行条件编译 #if V2007#else ((System.ComponentModel.IS

无法将类型为“System.Security.Principal.GenericIdentity”的对象强制转换为类型“System.Web.Security.FormsIdentity”。

这次的系统包含两个子系统,所以做了一个分角色的身份验证系统. web.config <system.web>中设置 <authentication mode="Forms"> <!--验证方式为窗体验证--> <forms name=".ASPXAUTH" loginUrl="~/login.aspx" protection="All" timeout="60" p

保存图片控件上的图片到本地 出现错误:无法将类型为“System.Windows.Media.Imaging.BitmapFrameDecode”的对象强制转换为类型“System.Windows.Media.Imaging.BitmapImage”。

保存图片控件上的图片到本地 出现错误:无法将类型为“System.Windows.Media.Imaging.BitmapFrameDecode”的对象强制转换为类型“System.Windows.Media.Imaging.BitmapImage”. try { System.Windows.Controls.MenuItem menuitem = sender as System.Windows.Controls.MenuItem; BitmapImage bitmap = (BitmapI

无法将类型为“System.Decimal”的对象强制转换为类型“System.Char[]”。

在用微软的SSIS操作ORACLE 数据源的时候碰到以下报错信息: [ADO NET Destination [13455]] 错误: 数据插入期间出现异常,从提供程序返回的消息为:无法将类型为"System.Decimal"的对象强制转换为类型"System.Char[]". SQL语句: select A FROM TABLE WHERE B .... 字段A为NUMBER类型,但是数据库中有空值,所以报错,只是报错信息不标准 SQL改为 SELECT case

System.InvalidCastException: 无法将类型为“DEduSys.SqlServerDal.sysManageUser”的对象强制转换为类型“DEduSys.IDal.IsysManageUser

出现 System.InvalidCastException: 无法将类型为“DEduSys.SqlServerDal.sysManageUser”的对象强制转换为类型“DEduSys.IDal.IsysManageUser”.这种类型错误,多数是数据层相关类没有实现相对应的接口.例如  public  class sysManageUser改为   public  class sysManageUser:IsysManageUser即可

无法将类型为“System.Xml.XmlComment”的对象强制转换为类型“System.Xml.XmlElement”

今天开发C#项目时,有一个需要读取XML的功能点.编码过程中遇到了如标题所示的异常,如下图所示: 查询官网后得知XmlComment是注释节点的类型,如下图所示: 于是得出结论,使用XmlDocument去解析XML文件时,注释也会作为一个节点被加载到节点列表里.因此后续如果需要添加注释的话,可以考虑在节点里增加一个属性“comment”或者“text”专门用来存放注释信息,这样可以大大增加XML文件对于其他程序的可读性.如果说仅仅是自己使用的话,可以在程序里进行类型的判断.遍历XML节点时判断

System.Windows.Forms.Control : Component, IOleControl, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject....

#region 程序集 System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll #endregion using System.Collections; using System.ComponentModel; using Syst

System.Windows.Forms.ListView : Control

#region 程序集 System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll #endregion using System.Collections; using System.ComponentModel; using Syst

System.Windows.Forms

1 File: winforms\Managed\System\WinForms\DataGridView.cs 2 Project: ndp\fx\src\System.Windows.Forms.csproj (System.Windows.Forms) 3 4 //------------------------------------------------------------------------------ 5 // <copyright file="DataGridVi