わかった。これはちょっとおかしな話です。
Access データベースのフロントエンドをコーディングしています (車輪の再発明です)。このフロントエンドはシンプルです。個人が新しいエントリを追加するか、既存のエントリを検索できます。それらの両方が正常に機能しています。プログラムは自己更新ですが、非常に単純です。実行されたプログラムの現在のファイル バージョン (アセンブリではない) を比較し、自身をリモート ドライブのバージョンと参照してどちらが新しいかを確認します。リモート ドライブの実行可能ファイルの方が新しい場合は、現在のプログラムを強制終了し、新しいプログラムを古いプログラムと同じディレクトリにコピーして、新しいプログラムを自動的に開くことでスクリプトを更新するバッチ ファイルを生成します。この更新チェックは、ユーザーがプログラムを開くたびに行われます。
それが関連しているかどうかはわかりませんが、最近、そのプロセスを編集して XP と 7 の両方で動作するようにしました。そのため、ファイル パス (ドキュメントと設定 - XP) のスペースに対応するように変更する必要がありました。それはすべて元気でダンディです。
どこからともなく (どうやら)、プログラムは私のテスト XP マシン (2 つの異なる XP マシンで検証済み) で一貫してクラッシュし始めました。私の個人用マシンは 7 を実行しており、アップデートを含め、希望どおりに動作します。
XP でのクラッシュは、ホーム フォームの InitializeComponent() で処理されない例外です。私のフォームの簡単なレイアウトは次のとおりです。
- BaseForm.cs - メイン フォーム/親。.exe を開いたときに開始する最初のフォーム。GUI はなく、他の子を呼び出すためだけに存在します。
- Home.cs - BaseForm の子。追加/検索エントリなどの他のフォームを呼び出すためのホーム GUI とボタンが含まれています。
Home.cs フォームをロードする前にクラッシュするため、他のフォームには入りません。
次のコンストラクター内の Home の InitializeComponent() 内でのクラッシュに絞り込みました。
public Home(string DB)
{
InitializeComponent();
database = DB;
lblVersion.Text = "Version: " + FileVersionInfo.GetVersionInfo(Directory.GetCurrentDirectory() + "\\KnowledgeBase.exe").ProductVersion;
}
と次のメッセージが表示されます。ざらざらしていて申し訳ありません...スクリーンショットのスクリーンショット: 担当者が10人未満で、エラーを入力しません:
これが私の InitializeComponent() です
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Home));
this.btnNewEntry = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnSearch = new System.Windows.Forms.Button();
this.lblVersion = new System.Windows.Forms.Label();
this.linklblChangelog = new System.Windows.Forms.LinkLabel();
this.button1 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// btnNewEntry
//
this.btnNewEntry.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnNewEntry.Location = new System.Drawing.Point(391, 407);
this.btnNewEntry.Name = "btnNewEntry";
this.btnNewEntry.Size = new System.Drawing.Size(142, 43);
this.btnNewEntry.TabIndex = 0;
this.btnNewEntry.Text = "Add new entry";
this.btnNewEntry.UseVisualStyleBackColor = true;
this.btnNewEntry.Click += new System.EventHandler(this.btnNewEntry_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(184, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(349, 31);
this.label1.TabIndex = 1;
this.label1.Text = "Nationwide Knowledgebase";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(280, 41);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(147, 26);
this.label2.TabIndex = 2;
this.label2.Text = "RADS Edition";
//
// btnSearch
//
this.btnSearch.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSearch.Location = new System.Drawing.Point(190, 407);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(142, 43);
this.btnSearch.TabIndex = 3;
this.btnSearch.Text = "Search database";
this.btnSearch.UseVisualStyleBackColor = true;
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// lblVersion
//
this.lblVersion.AutoSize = true;
this.lblVersion.Location = new System.Drawing.Point(3, 485);
this.lblVersion.Name = "lblVersion";
this.lblVersion.Size = new System.Drawing.Size(64, 13);
this.lblVersion.TabIndex = 4;
this.lblVersion.Text = "Version: null";
//
// linklblChangelog
//
this.linklblChangelog.AutoSize = true;
this.linklblChangelog.Location = new System.Drawing.Point(96, 485);
this.linklblChangelog.Name = "linklblChangelog";
this.linklblChangelog.Size = new System.Drawing.Size(58, 13);
this.linklblChangelog.TabIndex = 5;
this.linklblChangelog.TabStop = true;
this.linklblChangelog.Text = "Changelog";
//
// button1
//
this.button1.Location = new System.Drawing.Point(640, 480);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 7;
this.button1.Text = "test";
this.button1.UseVisualStyleBackColor = true;
this.button1.Visible = false;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(232, 85);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(247, 256);
this.pictureBox1.TabIndex = 8;
this.pictureBox1.TabStop = false;
//
// Home
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
this.ClientSize = new System.Drawing.Size(727, 512);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.linklblChangelog);
this.Controls.Add(this.lblVersion);
this.Controls.Add(this.btnSearch);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnNewEntry);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Home";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Home";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Home_FormClosed);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
XP でのみ InitializeComponent() でクラッシュするのはなぜですか? そして、なぜそれを始めたのですか?開発の最初の数週間は、この分野で順調に進みました。
Update() プロセス全体を取り出してみましたが、何も変わりません。
読んでくれてありがとう。
更新: Jon Skeet は、私が使用していたアイコンがプログラムをクラッシュさせたと示唆しています。それが判明しました。アイコンを削除すると、XP でフォームが適切に機能するようになります (これも 7 では問題になりませんでした)。さらに興味深いことに、私はこのアイコンを長い間開発に使用していたため、問題が顕在化するのに 2 週間かかりました。なぜそれが起こったのかについては後で説明しますが、それまでに書くべきコードが他にもあります。
みんな、ありがとう。