
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
namespace WindowsFormsApplication1
{
partial class Form1
{
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
/// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>
protected override void Dispose( bool disposing )
{
if( disposing && ( components != null ) )
{
components.Dispose();
}
base.Dispose( disposing );
}
#region Windows フォーム デザイナで生成されたコード
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point( 12, 9 );
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size( 35, 12 );
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// button1
//
this.button1.Location = new System.Drawing.Point( 197, 27 );
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size( 75, 23 );
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 12F );
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size( 284, 62 );
this.Controls.Add( this.button1 );
this.Controls.Add( this.label1 );
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout( false );
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
}
}
アプリケーションのCOMスレッド モデルが、STAであることを表す属性です。この属性はエントリポイントとなるメソッド、つまりC#とVisual BasicではMain()に適用しなければ効果はありません。Remarks - STAThreadAttribute Class (System) | Microsoft Learn
[STAThread]
static void Main(string[] args)
{
}