为了在类中禁用组件设计器,只需向其添加[System.ComponentModel.DesignerCategory("")]属性即可,但它不适用于任何代中从此类派生的任何类.例如:
[System.ComponentModel.DesignerCategory("")]
public class A:ServiceBase { } //Designer is disabled here
public class B:A {} //Designer is enabled here
[System.ComponentModel.DesignerCategory("")]
public class B:A {} //Designer is enabled here too
[System.ComponentModel.DesignerCategory("Code")]
public class B:A {} //Designer is enabled even here
Run Code Online (Sandbox Code Playgroud)
当然,这发生在任何其他世代和排列中.例如
//Whatever attribute here
public class C:B {} //Designer is enabled here
Run Code Online (Sandbox Code Playgroud)
有没有人试图摆脱它?为什么组件模型尝试添加设计器支持,即使它在第一代中明确禁用?
谢谢