【问题标题】:Cannot view form - Designer Error无法查看表单 - 设计器错误
【发布时间】:2017-02-21 21:25:33
【问题描述】:

我的设计器代码中出现错误“设计器无法处理第 163 行的代码,请参阅任务列表了解详细信息。方法 'InitializeComponent' 中的代码由设计器生成,不应手动修改. 请删除所有更改并尝试再次打开设计器。”

任务列表显示“找不到与此错误相关的帮助主题”

这是第 163 行

this.textBox_Command.TabIndex = 15;

这是整个设计器文件。我花了几个小时试图逐行注释掉每一行,但当我这样做时它只会抱怨前一行。

***** 设计器文件 *****

namespace Print
{
    partial class Form_Print
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.button_Print = new System.Windows.Forms.Button();
            this.comboBox_Bartender_File = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.button_flush_cache = new System.Windows.Forms.Button();
            this.checkBox_Show_Bartender = new System.Windows.Forms.CheckBox();
            this.checkBoxPause = new System.Windows.Forms.CheckBox();
            this.checkBox_FlucheCache = new System.Windows.Forms.CheckBox();
            this.textBox_Log = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.panel1 = new System.Windows.Forms.Panel();
            this.textBox_Command = new System.Windows.Forms.TextBox();
            this.label6 = new System.Windows.Forms.Label();
            this.button_Check_Sensor = new System.Windows.Forms.Button();
            this.rtxtRecv = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.textBox_IP_Address = new System.Windows.Forms.TextBox();
            this.checkBox_Using_Sato = new System.Windows.Forms.CheckBox();
            this.label3 = new System.Windows.Forms.Label();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // button_Print
            // 
            this.button_Print.Location = new System.Drawing.Point(12, 121);
            this.button_Print.Name = "button_Print";
            this.button_Print.Size = new System.Drawing.Size(282, 113);
            this.button_Print.TabIndex = 0;
            this.button_Print.Text = "Print";
            this.button_Print.UseVisualStyleBackColor = true;
            this.button_Print.Click += new System.EventHandler(this.Print_Click);
            // 
            // comboBox_Bartender_File
            // 
            this.comboBox_Bartender_File.DropDownWidth = 243;
            this.comboBox_Bartender_File.FormattingEnabled = true;
            this.comboBox_Bartender_File.Items.AddRange(new object[] {
            "c:\\PrintingApplication\\BartenderFiles\\16353-002a.btw,SATO CL4NX 609dpi",
            "c:\\PrintingApplication\\BartenderFiles\\16353-002a.btw,SATO CL4NX 609dpi"});
            this.comboBox_Bartender_File.Location = new System.Drawing.Point(91, 32);
            this.comboBox_Bartender_File.Name = "comboBox_Bartender_File";
            this.comboBox_Bartender_File.Size = new System.Drawing.Size(191, 21);
            this.comboBox_Bartender_File.TabIndex = 3;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(9, 40);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(76, 13);
            this.label1.TabIndex = 2;
            this.label1.Text = "BarTender File";
            // 
            // button_flush_cache
            // 
            this.button_flush_cache.Location = new System.Drawing.Point(727, 40);
            this.button_flush_cache.Name = "button_flush_cache";
            this.button_flush_cache.Size = new System.Drawing.Size(150, 51);
            this.button_flush_cache.TabIndex = 5;
            this.button_flush_cache.Text = "Flush Cache";
            this.button_flush_cache.UseVisualStyleBackColor = true;
            this.button_flush_cache.Click += new System.EventHandler(this.button_flush_cache_Click);
            // 
            // checkBox_Show_Bartender
            // 
            this.checkBox_Show_Bartender.AutoSize = true;
            this.checkBox_Show_Bartender.Location = new System.Drawing.Point(12, 12);
            this.checkBox_Show_Bartender.Name = "checkBox_Show_Bartender";
            this.checkBox_Show_Bartender.Size = new System.Drawing.Size(195, 17);
            this.checkBox_Show_Bartender.TabIndex = 6;
            this.checkBox_Show_Bartender.Text = "Show BarTender During Processing";
            this.checkBox_Show_Bartender.UseVisualStyleBackColor = true;
            // 
            // checkBoxPause
            // 
            this.checkBoxPause.AutoSize = true;
            this.checkBoxPause.Location = new System.Drawing.Point(305, 12);
            this.checkBoxPause.Name = "checkBoxPause";
            this.checkBoxPause.Size = new System.Drawing.Size(165, 17);
            this.checkBoxPause.TabIndex = 10;
            this.checkBoxPause.Text = "Pause Printer after each label";
            this.checkBoxPause.UseVisualStyleBackColor = true;
            // 
            // checkBox_FlucheCache
            // 
            this.checkBox_FlucheCache.AutoSize = true;
            this.checkBox_FlucheCache.Location = new System.Drawing.Point(498, 12);
            this.checkBox_FlucheCache.Name = "checkBox_FlucheCache";
            this.checkBox_FlucheCache.Size = new System.Drawing.Size(413, 17);
            this.checkBox_FlucheCache.TabIndex = 6;
            this.checkBox_FlucheCache.Text = "Flush Cache between printouts of bartender files if the bartender filename change" +
    "s\r\n";
            this.checkBox_FlucheCache.UseVisualStyleBackColor = true;
            // 
            // textBox_Log
            // 
            this.textBox_Log.Location = new System.Drawing.Point(15, 322);
            this.textBox_Log.Multiline = true;
            this.textBox_Log.Name = "textBox_Log";
            this.textBox_Log.Size = new System.Drawing.Size(872, 145);
            this.textBox_Log.TabIndex = 11;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(14, 306);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(71, 13);
            this.label2.TabIndex = 12;
            this.label2.Text = "Message Log";
            // 
            // panel1
            // 
            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.panel1.Controls.Add(this.textBox_Command);
            this.panel1.Controls.Add(this.label6);
            this.panel1.Controls.Add(this.button_Check_Sensor);
            this.panel1.Controls.Add(this.rtxtRecv);
            this.panel1.Controls.Add(this.label5);
            this.panel1.Controls.Add(this.label4);
            this.panel1.Controls.Add(this.textBox_IP_Address);
            this.panel1.Controls.Add(this.checkBox_Using_Sato);
            this.panel1.Location = new System.Drawing.Point(305, 121);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(582, 198);
            this.panel1.TabIndex = 13;
            // 
            // textBox_Command
            // 
            this.textBox_Command.Location = new System.Drawing.Point(68, 92);
            this.textBox_Command.Name = "textBox_Command";
            this.textBox_Command.Size = new System.Drawing.Size(100, 20);
            this.textBox_Command.TabIndex = 15;
            this.textBox_Command.Text = "PD";
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(7, 100);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(54, 13);
            this.label6.TabIndex = 14;
            this.label6.Text = "Command";
            // 
            // button_Check_Sensor
            // 
            this.button_Check_Sensor.Location = new System.Drawing.Point(375, 20);
            this.button_Check_Sensor.Name = "button_Check_Sensor";
            this.button_Check_Sensor.Size = new System.Drawing.Size(75, 68);
            this.button_Check_Sensor.TabIndex = 13;
            this.button_Check_Sensor.Text = "Check Sensor";
            this.button_Check_Sensor.UseVisualStyleBackColor = true;
            this.button_Check_Sensor.Click += new System.EventHandler(this.button_Check_Sensor_Click);
            // 
            // rtxtRecv
            // 
            this.rtxtRecv.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
            this.rtxtRecv.Location = new System.Drawing.Point(86, 131);
            this.rtxtRecv.Multiline = true;
            this.rtxtRecv.Name = "rtxtRecv";
            this.rtxtRecv.Size = new System.Drawing.Size(482, 61);
            this.rtxtRecv.TabIndex = 12;
            this.rtxtRecv.Text = "Unknown";
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(7, 134);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(73, 13);
            this.label5.TabIndex = 11;
            this.label5.Text = "Sensor Status";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(4, 4);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(91, 13);
            this.label4.TabIndex = 1;
            this.label4.Text = "Printer IP Address";
            // 
            // textBox_IP_Address
            // 
            this.textBox_IP_Address.Location = new System.Drawing.Point(7, 20);
            this.textBox_IP_Address.Name = "textBox_IP_Address";
            this.textBox_IP_Address.Size = new System.Drawing.Size(307, 20);
            this.textBox_IP_Address.TabIndex = 0;
            this.textBox_IP_Address.Text = "10.162.21.11";
            // 
            // checkBox_Using_Sato
            // 
            this.checkBox_Using_Sato.AutoSize = true;
            this.checkBox_Using_Sato.Location = new System.Drawing.Point(7, 62);
            this.checkBox_Using_Sato.Name = "checkBox_Using_Sato";
            this.checkBox_Using_Sato.Size = new System.Drawing.Size(118, 17);
            this.checkBox_Using_Sato.TabIndex = 10;
            this.checkBox_Using_Sato.Text = "Using SATO Printer";
            this.checkBox_Using_Sato.UseVisualStyleBackColor = true;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(302, 100);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(118, 13);
            this.label3.TabIndex = 14;
            this.label3.Text = "SATO Specific Settings";
            // 
            // Form_Print
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(889, 474);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.textBox_Log);
            this.Controls.Add(this.checkBoxPause);
            this.Controls.Add(this.checkBox_FlucheCache);
            this.Controls.Add(this.checkBox_Show_Bartender);
            this.Controls.Add(this.button_flush_cache);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.comboBox_Bartender_File);
            this.Controls.Add(this.button_Print);
            this.Name = "Form_Print";
            this.Text = "*** SATO Printer Application FPA ***";
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button button_Print;
        private System.Windows.Forms.ComboBox comboBox_Bartender_File;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button button_flush_cache;
        private System.Windows.Forms.CheckBox checkBox_Show_Bartender;
        private System.Windows.Forms.CheckBox checkBoxPause;
        private System.Windows.Forms.CheckBox checkBox_FlucheCache;
        private System.Windows.Forms.TextBox textBox_Log;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.TextBox textBox_IP_Address;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Button button_Check_Sensor;
        private System.Windows.Forms.TextBox rtxtRecv;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.CheckBox checkBox_Using_Sato;
        private System.Windows.Forms.TextBox textBox_Command;
        private System.Windows.Forms.Label label6;
    }
}

调用堆栈

此错误的实例(一)

Print Form1.Designer.cs Line:163 Column:1   Hide Call Stack 

at Microsoft.VisualStudio.Design.Serialization.CodeDom.XML.CodeDomXmlProcessor.ParseXml(String xmlStream, CodeStatementCollection statementCollection, String fileName, String methodName)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.OnMethodPopulateStatements(Object sender, EventArgs e)
at System.CodeDom.CodeMemberMethod.get_Statements()
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)  

【问题讨论】:

  • 我假设在较早的阶段 WinForm 显示没有任何问题。你知道从那个版本到现在有什么变化吗?
  • 检查设计器视图中此表单属性下设置的tabIndex 是否实际为15。听起来您手动修改了此文件,这可能是导致问题的原因。在设计视图中按 (F4) 可以访问属性选项卡。
  • 关闭所有打开的与表单相关的文件。然后尝试编译您的项目并重新打开表单。问题还存在吗?
  • 我假设您尝试关闭所有窗口,然后关闭 Visual Studio,然后再次启动它。我还建议在重新启动 Visual Studio 之前删除项目中的所有临时文件。如果这不起作用,我建议,如果您在问题发生之前有备份,请查看是否仍然有效。如果不行,看看能不能新建一个默认项目,调出设计器。
  • 关闭视觉工作室。删除整个解决方案中的每个血腥 bin 和 obj 文件夹。重新打开视觉工作室。重建。

标签: c#


【解决方案1】:

使用您发布的设计器代码,我能够查看表单。我赌的是旧文件,或者 VS 只是变得“困惑”。我不能说比这更好了,这种事情我以前也发生过。

第一步是构建 -> 清洁解决方案。然后关闭并重新打开解决方案。

如果这不起作用,请确保执行上面提到的Dave SWill,并手动删除所有 /bin 和 /obj 文件夹。然后关闭并重新打开。

如果这些都不起作用,您可以通过打开项目(不打开表单)进行更多调试以查看问题所在,然后打开第二个空白 Visual Studio 窗口(无项目),然后使用“附加”功能以选择第一个 Visual Studio 窗口(单击“附加”后打开的列表中的“devenv.exe”)。接下来,打开您的表单,看看错误将您引导到哪里。

我知道这不是一个完整的解决方案,但希望它有助于解决问题的下一步。祝你好运,因为我知道玩弄工具既痛苦又没有效率。

【讨论】:

  • 用一个新表单从头开始并把所有代码都放进去可能会更快
  • 你绝对可以这样做,但我认为你已经在上面的评论中尝试过,所以我没有建议。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-02-28
  • 2015-11-24
  • 2017-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多