私はWinFormsアプリケーションで同様の効果を達成しようとしていますが、マスターフォームはASP.NETと同じです。私の最初の考えは、基本フォームを作成し、それを抽象として宣言することでしたが、コンパイラは私にこれをさせてくれません。抽象フォームWinFormsを使用して
public abstract partial class Master : Form
{
public Master()
{
InitializeComponent();
}
}
だから、私は2つの質問があります。
- はなぜコンパイラは、私がこれをやらせないのだろうか?間違った構文を使用していますか、これは真の制限です。
- 誰かがこれを行うには回避策またはより良い方法を提案できますか?
EDIT:
のInitializeComponentコード:
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.Menu = this.mainMenu1;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Text = "Master";
this.AutoScroll = true;
}
EDIT:
エラーが次のとおりです。私が達成しようとしている
The designer must create an instance of type 'Namespace.Master' but it cannot because the type is declared as abstract.
実際のコンパイラエラーは何ですか? –
コンパイルしようとしているスニペットが正確であれば、InitializeComponent()の定義を提供する必要があります – asawyer
抽象クラスのpublicコンストラクタについてresharperまたは何か不満がありますか? –