Why did Visual Studio mark my class as a component?

A class diagram

I have an instance that inserted some classes into this project, some from other projects. At some point, VS marked Class1 as a component (you can see from the icon shown in the screenshot above). Class2 OK. There is no difference in File Properties and there is no interesting difference in code between Class1 and Class2 (* except, see change below)

This does not prevent compilation or code execution. Is this a problem at all? This is inconvenient in that the IDE tries to open the Design window if you double-click the file.

How does this happen and how to fix it?

Edit: Actually, there are interesting differences in the code window. At least it should be, since deleting a large piece of code causes Solution Explorer to return the file to the class file. Restore the piece and the file returns to the component. Currently ... an investigation.

+7
source share
2 answers

I'm not sure why he does this, but I know how to get rid of him. Before you put your class:

 [System.ComponentModel.DesignerCategory("Code")] 

It should work.

+12
source

For the โ€œwhyโ€ part of your question (taken from this post , which appears to be a duplicate):

A class with System.ComponentModel.Component along the path of their inheritance is automatically processed as "components" in Visual Studio (2008), invoking another icon for the source file:

+3
source

All Articles