-2

PLC の診断アプリケーションを作成しています。UserControl から継承された 1 つのフォームといくつかのコントロールがあります。この Controls I スイッチ。1 つのビューは、ダッシュボード、グラフなどです。グラフの実行中に例外が発生します。Form1.Designer.cs の "base.Dispose(disposing)" 行に例外が表示されます。どうすれば修正できますか?アイデアをありがとう。


Form1.Designer.csのコードです。base.Dispose(破棄)の行にエラーが表示されます。基本的に、コードのこの部分が何をするのかわかりません。直せないなんて。それがどのように機能するか、誰か教えてもらえますか?この部分はいつ呼ばれますか?私のプログラムでは Dispose() メソッドの使用は見当たりません。(UserControl から継承された) 各コントロールのメソッドをオーバーライドするだけです。ありがとう

namespace WindowsFormsApplication1 { partial class Form1 { /// /// 必要なデザイナー変数。/// プライベート System.ComponentModel.IContainer コンポーネント = 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)
    {
        /*Updated 8.4.2013*/
        //try
        //{
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        //}
        //catch { }
    }

    #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()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
        this.statusStrip1 = new System.Windows.Forms.StatusStrip();
        this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
        this.btn_ChangeLanguage = new System.Windows.Forms.Button();
        this.pictureBox1 = new System.Windows.Forms.PictureBox();
        this.Zobraz_Palubka = new System.Windows.Forms.Button();
        this.Zobraz_Verzi = new System.Windows.Forms.Button();
        this.Zobraz_error = new System.Windows.Forms.Button();
        this.Zobraz_Nastaveni = new System.Windows.Forms.Button();
        this.Zobraz_TestIO = new System.Windows.Forms.Button();
        this.Zobraz_monitor = new System.Windows.Forms.Button();
        this.statusStrip1.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
        this.SuspendLayout();
        // 
        // statusStrip1
        // 
        this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.toolStripStatusLabel1});
        resources.ApplyResources(this.statusStrip1, "statusStrip1");
        this.statusStrip1.Name = "statusStrip1";
        // 
        // toolStripStatusLabel1
        // 
        this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
        resources.ApplyResources(this.toolStripStatusLabel1, "toolStripStatusLabel1");
        // 
        // btn_ChangeLanguage
        // 
        this.btn_ChangeLanguage.Image = global::WindowsFormsApplication1.Properties.Resources.flag_cze_mini;
        resources.ApplyResources(this.btn_ChangeLanguage, "btn_ChangeLanguage");
        this.btn_ChangeLanguage.Name = "btn_ChangeLanguage";
        this.btn_ChangeLanguage.UseVisualStyleBackColor = true;
        this.btn_ChangeLanguage.Click += new System.EventHandler(this.btn_ChangeLanguage_Click);
        this.btn_ChangeLanguage.MouseEnter += new System.EventHandler(this.Zobraz_Nastaveni_MouseEnter);
        this.btn_ChangeLanguage.MouseLeave += new System.EventHandler(this.Zobraz_Nastaveni_MouseLeave);
        // 
        // pictureBox1
        // 
        this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
        this.pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.trojuhelnik;
        resources.ApplyResources(this.pictureBox1, "pictureBox1");
        this.pictureBox1.Name = "pictureBox1";
        this.pictureBox1.TabStop = false;
        // 
        // Zobraz_Palubka
        // 
        this.Zobraz_Palubka.Image = global::WindowsFormsApplication1.Properties.Resources.tachometr_mini;
        resources.ApplyResources(this.Zobraz_Palubka, "Zobraz_Palubka");
        this.Zobraz_Palubka.Name = "Zobraz_Palubka";
        this.Zobraz_Palubka.UseVisualStyleBackColor = true;
        this.Zobraz_Palubka.Click += new System.EventHandler(this.Zobraz_Click);
        this.Zobraz_Palubka.MouseEnter += new System.EventHandler(this.Zobraz_Nastaveni_MouseEnter);
        this.Zobraz_Palubka.MouseLeave += new System.EventHandler(this.Zobraz_Nastaveni_MouseLeave);
        // 
        // Zobraz_Verzi
        // 
        this.Zobraz_Verzi.Image = global::WindowsFormsApplication1.Properties.Resources.info_mini;
        resources.ApplyResources(this.Zobraz_Verzi, "Zobraz_Verzi");
        this.Zobraz_Verzi.Name = "Zobraz_Verzi";
        this.Zobraz_Verzi.UseVisualStyleBackColor = true;
        this.Zobraz_Verzi.Click += new System.EventHandler(this.Zobraz_Click);
        this.Zobraz_Verzi.MouseEnter += new System.EventHandler(this.Zobraz_Nastaveni_MouseEnter);
        this.Zobraz_Verzi.MouseLeave += new System.EventHandler(this.Zobraz_Nastaveni_MouseLeave);
        // 
        // Zobraz_error
        // 
        this.Zobraz_error.Image = global::WindowsFormsApplication1.Properties.Resources.error1_mini;
        resources.ApplyResources(this.Zobraz_error, "Zobraz_error");
        this.Zobraz_error.Name = "Zobraz_error";
        this.Zobraz_error.UseVisualStyleBackColor = true;
        this.Zobraz_error.Click += new System.EventHandler(this.Zobraz_Click);
        this.Zobraz_error.MouseEnter += new System.EventHandler(this.Zobraz_Nastaveni_MouseEnter);
        this.Zobraz_error.MouseLeave += new System.EventHandler(this.Zobraz_Nastaveni_MouseLeave);
        // 
        // Zobraz_Nastaveni
        // 
        this.Zobraz_Nastaveni.Image = global::WindowsFormsApplication1.Properties.Resources.settings_mini;
        resources.ApplyResources(this.Zobraz_Nastaveni, "Zobraz_Nastaveni");
        this.Zobraz_Nastaveni.Name = "Zobraz_Nastaveni";
        this.Zobraz_Nastaveni.UseVisualStyleBackColor = true;
        this.Zobraz_Nastaveni.Click += new System.EventHandler(this.Zobraz_Click);
        this.Zobraz_Nastaveni.MouseEnter += new System.EventHandler(this.Zobraz_Nastaveni_MouseEnter);
        this.Zobraz_Nastaveni.MouseLeave += new System.EventHandler(this.Zobraz_Nastaveni_MouseLeave);
        // 
        // Zobraz_TestIO
        // 
        this.Zobraz_TestIO.Image = global::WindowsFormsApplication1.Properties.Resources.testIO_mini;
        resources.ApplyResources(this.Zobraz_TestIO, "Zobraz_TestIO");
        this.Zobraz_TestIO.Name = "Zobraz_TestIO";
        this.Zobraz_TestIO.UseVisualStyleBackColor = true;
        this.Zobraz_TestIO.Click += new System.EventHandler(this.Zobraz_Click);
        this.Zobraz_TestIO.MouseEnter += new System.EventHandler(this.Zobraz_Nastaveni_MouseEnter);
        this.Zobraz_TestIO.MouseLeave += new System.EventHandler(this.Zobraz_Nastaveni_MouseLeave);
        // 
        // Zobraz_monitor
        // 
        this.Zobraz_monitor.Image = global::WindowsFormsApplication1.Properties.Resources.line_graph_icon_mini;
        resources.ApplyResources(this.Zobraz_monitor, "Zobraz_monitor");
        this.Zobraz_monitor.Name = "Zobraz_monitor";
        this.Zobraz_monitor.UseVisualStyleBackColor = true;
        this.Zobraz_monitor.Click += new System.EventHandler(this.Zobraz_Click);
        this.Zobraz_monitor.MouseEnter += new System.EventHandler(this.Zobraz_Nastaveni_MouseEnter);
        this.Zobraz_monitor.MouseLeave += new System.EventHandler(this.Zobraz_Nastaveni_MouseLeave);
        // 
        // Form1
        // 
        resources.ApplyResources(this, "$this");
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.Controls.Add(this.btn_ChangeLanguage);
        this.Controls.Add(this.pictureBox1);
        this.Controls.Add(this.Zobraz_Palubka);
        this.Controls.Add(this.Zobraz_Verzi);
        this.Controls.Add(this.Zobraz_error);
        this.Controls.Add(this.statusStrip1);
        this.Controls.Add(this.Zobraz_Nastaveni);
        this.Controls.Add(this.Zobraz_TestIO);
        this.Controls.Add(this.Zobraz_monitor);
        this.Name = "Form1";
        this.statusStrip1.ResumeLayout(false);
        this.statusStrip1.PerformLayout();
        ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    private System.Windows.Forms.Button Zobraz_monitor;
    private System.Windows.Forms.Button Zobraz_Nastaveni;
    private System.Windows.Forms.StatusStrip statusStrip1;
    private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
    private System.Windows.Forms.Button Zobraz_TestIO;
    private System.Windows.Forms.Button Zobraz_error;
    private System.Windows.Forms.Button Zobraz_Verzi;
    private System.Windows.Forms.Button Zobraz_Palubka;
    private System.Windows.Forms.PictureBox pictureBox1;
    private System.Windows.Forms.Button btn_ChangeLanguage;
}

}


例外の詳細は次のとおりです。

System.InvalidOperationException はユーザー コードによって処理されませんでした。Source=System.Windows.Forms StackTrace: System.Windows.Forms.Control.get_Handle() で System.Windows.Forms.Form.UpdateMenuHandles(MainMenu メニュー、Boolean forceRedraw) で System.Windows.Forms.Form.UpdateMenuHandles() でSystem.Windows.Forms.Form.MenuChanged (Int32 変更、メニュー メニュー) で System.Windows.Forms.Form.Dispose (ブール値の破棄) で WindowsFormsApplication1.Form1.Dispose (ブール値の破棄) で c:__プロジェクト__\C#\RailJay Diagnostic SW\20130408\Motor\Motor\Form1.Designer.cs: System.Windows.Forms.ApplicationContext.Dispose(Boolean disposing) の System.ComponentModel.Component.Dispose() の 23 行目 System.Windows .Forms.Application.ThreadContext.DisposeThreadWindows() InnerException:

4

2 に答える 2

1

DisposeGUI スレッド以外のスレッドから呼び出しているようです。そんなことはできません。

于 2013-04-08T12:52:42.097 に答える
0

もっと具体的にする必要があります-おそらく、あなたがやろうとしていることにいくつかのコードを追加しますか?

[編集]

ジムが述べたように、別のスレッドからフォームを参照しています。

例外の詳細は次のとおりです。

System.InvalidOperationException はユーザー コードによって処理されませんでした。

これは、Form1 が作成されていないスレッドから Form1 を破棄しようとしていることを意味します。

アプリケーションで個別のスレッドが実行されていますか? もしそうなら、これが最初の調査場所です。

コード内のどこかで Form1 を閉じていますか?

于 2013-04-08T12:13:51.923 に答える