Visual Studio 2008 表单继承和泛型加载失败
给定以下继承树:
我有一个
public class BaseForm : Form
这是项目(或大多数)中所有 WinForm 的基本表单,包含一些基本内容。
后来,当泛型出现时,我创建了一个
public abstract partial class GenericObjectListBase<T> : BaseForm
最后,我用一个专门化了这个:
public partial class MySpecialList : GenericObjectListBase<MySpeciaType>
一切都有效,但设计师在最后一个“MySpecialList”中不起作用。
我读过 这个问题并回答,但我不完全确定它如何适用于我,因为我正在尝试查看“非通用”类(MySPecialList)。无论哪种情况,我得到的错误都是相同的。
无法显示此文件的设计器,因为无法设计其中的任何类... bla bla bla(检查其他问题以查看错误)。
知道存在某种“已知限制”,您是否有“已知解决方法”?
Given the following inheritance tree:
I have a
public class BaseForm : Form
This is the base form for all WinForms in the project (or most) and contains some basic stuff.
Later in time, when Generics came, I created a
public abstract partial class GenericObjectListBase<T> : BaseForm
And finally, I specialized that one with a:
public partial class MySpecialList : GenericObjectListBase<MySpeciaType>
It all works, but designer doesn’t work in the last “MySpecialList”.
I’ve read this question and answer, but I’m not entirely sure how it applies to me, given that I’m trying to see a “non-generic” class (MySPecialList). In either case, the error I get is the same.
The designer could not be shown for this file because none of the classes within it can be designed… bla bla bla (check the other question to see the error).
Knowing that there’s some sort of “known limitation”, do you have a “known workaround”?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个已知问题。 VS设计者不会让你在继承树的中间有一个抽象类。
不幸的是,但事实就是如此。最好的选择是使 GenericObjectListBase 成为一个具体的类。
This is a known problem. The VS designer will not let you have an abstract class in the middle of the inheritance tree.
Unfortunate, but that's the way it is. The best option is to make GenericObjectListBase a concrete class.