如何继承通用表单并在 Visual Studio 设计器中打开它?

How to inherit a generic form and open it in the Visual Studio designer?

在我的应用程序中,我有一个 BaseForm,其中有一个通用成员:

public partial class BaseForm<T> : Form where T : Presenter
{
    protected T Presenter;

    public BaseForm()
    {
        InitializeComponent();
    }
}

现在我需要的是有一个从我的 BaseForm 继承的表单

public partial class SampleForm : BaseForm<SamplePresenter>
{
    public SampleForm()
    {
        InitializeComponent();
        Presenter = new SamplePresenter();
    }
}

问题是 Visual Studio 设计器没有显示我的 SampleForm 来自 BaseForm<T>

它给出了这个警告:

Warning 1 The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:

SampleForm --- The base class 'Invoice.BaseForm' could not be loaded. Ensure the assembly has been referenced and that all projects have been built. 0 0

我该如何克服这个问题?

P.S。我查看了 this post 但并没有真正了解如何解决这个问题。

设计者不支持,如post所述。

你需要这个基地class:

public partial class SampleFormIntermediate : BaseForm<SamplePresenter>
{
    public SampleFormIntermediate()
    {
        InitializeComponent();
        Presenter = new SamplePresenter();
    }
}

并且您需要为 Visual Studio 设计师使用此 class:

public partial class SampleForm : SampleFormIntermediate
{
}

这样,Visual Studio'understands'在设计器里打开什么,怎么打开