Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable designer in derived classes in following generations

In order to disable component designer in classes it is simple to add just [System.ComponentModel.DesignerCategory("")] attribute to it, however it does not work for any classes derived from this class in any generation. E.g:

[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

This happens, of course, in any other generations and permutations. E.g.

//Whatever attribute here
public class C:B {} //Designer is enabled here

Does anybody ever tried to get rid of it? Why component model tries to add designer support even if it explicitely disabled in first generation?

Thank you

like image 705
Tamir Avatar asked Jan 24 '12 09:01

Tamir


1 Answers

The reason for such behaviour is cached referenced assemblies. To solve it, remove reference to the assembly contained base server with attribute and add it again. In this case Visual Studio rebuild project and will not define default editor to derrived class.

like image 127
Tamir Avatar answered Nov 14 '22 10:11

Tamir