破棄されたオブジェクトにアクセスできませんというエラー メッセージが表示されます。オブジェクト名: 'ApplicationProperties'。フォームを閉じた後に再度開こうとしたとき。これはフォームの終了によるものであり、終了はフォームの「破棄」であることに気付いたので、すべての承認ボタンとキャンセル ボタン (フォームを閉じるボタン) に次のコードを追加しました。
 this.Hide(); 
 this.Parent = null;
このコードはフォームを隠しているだけです。フォームを閉じません。
私の問題は、フォームの「x」ボタンをクリックしてから、フォームを再度開こうとすると、まだエラーメッセージが表示されることです。次のようなフォームの既存の機能を変更するために、いくつかの異なる方法を試しました。
    private void ApplicationProperties_FormClosing(object sender, FormClosingEventArgs e)
    {
        //Hiding the window, because closing it makes the window unaccessible.
        this.Hide();
        this.Parent = null;
    }
しかし、これは私に運をもたらしませんでした。誰かがこの問題を解決する方法を知っているかどうか疑問に思っていました。これは、キャンセル ボタンと同意ボタン内で機能しているコードです。フォームを閉じるすべてのボタンで同じです。
    private void OptionsCancelbtn_Click(object sender, EventArgs e)
    {
        //Hiding the window, because closing it makes the window unaccessible.
        this.Hide();
        this.Parent = null;
    }
form1 のクラスの先頭でインスタンスを宣言し、form1 内に form2 を開くボタンを配置しました。
public partial class MainBox : Form
{
    //Making a name for the ApplicationProperties form. It can be opened when called.
    ApplicationProperties ApplicationPropertiesWindow = new ApplicationProperties();
    private void ApplicationPropertiesbtn_Click(object sender, EventArgs e)
    {
        //Show the properties window.
        ApplicationPropertiesWindow.Show();
    }//End ApplicationProperties button.
 }
2 番目のフォームで「x」ボタンを使用してプログラムを閉じた後、エラー メッセージが発生するため、再び form2 にアクセスできません。ApplicationPropertiesWindow.Show();
form2 内には、次のコードがあります。
public partial class ApplicationProperties : Form
{
    //Creates and sets the instance MainBoxWindow.
    public MainBox MainBoxWindow { get; set; }