简体   繁体   English

C#中的组件抛出错误

[英]Component throwing errors in c#

I've got a small form aplication, that uses a component made by myself.The only problem is, after every run of the program the form throws some error becouse in the Designer of the form for some reasons where the component object is called the IDE adds an formProduse. 我有一个小的表单应用程序,它使用我自己制作的组件。唯一的问题是,在每次运行该程序后,由于某些原因,表单的设计器都会在表单的设计器中引发一些错误,其中组件对象称为IDE添加了formProduse。 before. 之前。 Like this 像这样

private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.Windows.Forms.Label iDProdusLabel;
            System.Windows.Forms.Label tipologieLabel;
            System.Windows.Forms.Label descriereLabel;
            System.Windows.Forms.Label uMLabel;
            System.Windows.Forms.Label denumireLabel;
            System.Windows.Forms.Label denumireALabel;
            System.Windows.Forms.Label tVALabel;
            System.Windows.Forms.Label greutateLabel;
            System.Windows.Forms.Label codFurnizorLabel;
            System.Windows.Forms.Label codOpAdaugLabel;
            System.Windows.Forms.Label dataAdaugLabel;
            System.Windows.Forms.Label codOpModificLabel;
            System.Windows.Forms.Label dataModificLabel;
            this.dmProduse = new formProduse.dmProduse(this.components);
            this.tabControl1 = new System.Windows.Forms.TabControl();
            this.tabPageInspectare = new System.Windows.Forms.TabPage();
            this.dataGridView1 = new System.Windows.Forms.DataGridView();
            this.spProduseInspectareBindingSource = new System.Windows.Forms.BindingSource(this.components);
            this.spProduse_Inspectare = new formProduse.spProduse_Inspectare();
            this.tabPage2 = new System.Windows.Forms.TabPage();
            this.button1 = new System.Windows.Forms.Button();
            this.iDProdusTextBox = new System.Windows.Forms.TextBox();
            this.spProduse_InspBindingSource = new System.Windows.Forms.BindingSource(this.components);
            this.tipologieTextBox = new System.Windows.Forms.TextBox();
            this.descriereTextBox = new System.Windows.Forms.TextBox();
            this.uMTextBox = new System.Windows.Forms.TextBox();
            this.denumireTextBox = new System.Windows.Forms.TextBox();
            this.denumireATextBox = new System.Windows.Forms.TextBox();
            this.tVATextBox = new System.Windows.Forms.TextBox();
            this.greutateTextBox = new System.Windows.Forms.TextBox();
            this.codFurnizorTextBox = new System.Windows.Forms.TextBox();
            this.codOpAdaugTextBox = new System.Windows.Forms.TextBox();
            this.dataAdaugDateTimePicker = new System.Windows.Forms.DateTimePicker();
            this.codOpModificTextBox = new System.Windows.Forms.TextBox();
            this.dataModificDateTimePicker = new System.Windows.Forms.DateTimePicker();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.aToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.sToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.mToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.spProduse_InspTableAdapter = new formProduse.spProduse_InspectareTableAdapters.spProduse_InspTableAdapter();
            this.tableAdapterManager = new formProduse.spProduse_InspectareTableAdapters.TableAdapterManager();
            iDProdusLabel = new System.Windows.Forms.Label();
            tipologieLabel = new System.Windows.Forms.Label();
            descriereLabel = new System.Windows.Forms.Label();
            uMLabel = new System.Windows.Forms.Label();
            denumireLabel = new System.Windows.Forms.Label();
            denumireALabel = new System.Windows.Forms.Label();
            tVALabel = new System.Windows.Forms.Label();
            greutateLabel = new System.Windows.Forms.Label();
            codFurnizorLabel = new System.Windows.Forms.Label();
            codOpAdaugLabel = new System.Windows.Forms.Label();
            dataAdaugLabel = new System.Windows.Forms.Label();
            codOpModificLabel = new System.Windows.Forms.Label();
            dataModificLabel = new System.Windows.Forms.Label();
            this.tabControl1.SuspendLayout();
            this.tabPageInspectare.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.spProduseInspectareBindingSource)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.spProduse_Inspectare)).BeginInit();
            this.tabPage2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.spProduse_InspBindingSource)).BeginInit();
            this.menuStrip1.SuspendLayout();
            this.SuspendLayout();

If I remove all the 5 appearance of the formProduse. 如果我删除formProduse的所有5个外观 the program runs ok. 该程序运行正常。

My errors are 我的错误是

Error   1   'formProduse.formProduse.dmProduse' is a 'field' but is used like a 'type'  D:\C# Projects\Restaurant2\formProduse\formProduse\formProduse.Designer.cs  45  46  formProduse
Error   2   'formProduse.formProduse.spProduse_Inspectare' is a 'field' but is used like a 'type'   D:\C# Projects\Restaurant2\formProduse\formProduse\formProduse.Designer.cs  50  57  formProduse
Error   3   The type name 'spProduse_InspectareTableAdapters' does not exist in the type 'formProduse.formProduse'  D:\C# Projects\Restaurant2\formProduse\formProduse\formProduse.Designer.cs  71  63  formProduse
Error   4   The type name 'spProduse_InspectareTableAdapters' does not exist in the type 'formProduse.formProduse'  D:\C# Projects\Restaurant2\formProduse\formProduse\formProduse.Designer.cs  72  56  formProduse
Error   5   'formProduse.formProduse' does not contain a definition for 'spProduse_InspectareTableAdapters' D:\C# Projects\Restaurant2\formProduse\formProduse\formProduse.Designer.cs  468 64  formProduse



 public partial class dmProduse : Component


    public dmProduse(IContainer container)


   {
        container.Add(this);
        InitializeComponent();
        restaurantConnString = "Data Source=SEBIPC;Initial Catalog=Restaurant;Persist Security Info=True;User ID=sa;Password=*";
        conn = new SqlConnection(restaurantConnString);
        conn.Open();
    }

and

 public partial class spProduse_Inspectare : global::System.Data.DataSet

It's a dataset produced by a StoredProcedure 这是由StoredProcedure产生的数据集

The compiler is confusing the field names with the declared names for the inner classes created by the designer. 编译器正在将字段名称与设计人员创建的内部类的声明名称混淆。 To remove the conflict you need to make sure that the field names do not match the class names, in your case, for example, using dmProduse1 instead of dmProduse . 要消除冲突,您需要确保字段名称与类名称不匹配,例如,使用dmProduse1而不是dmProduse

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM