Вопрос

Is there any way to tell Visual Studio that I want to treat my class as a regular class and not a component? My class is declared like this:

public class WebDavClient : WebClient
{
}

I guess that, because WebClient derives from System.ComponentModel.Component, Visual Studio assumes it is a component. So double clicking the file in Solution Explorer brings up a designer surface instead of the code. Moreover, if I add another class before the declaration above, double clicking the file in Solution Explorer gives me a "The class WebDavClient can be designed, but is not the first class in the file" error.

In all cases, I only want to treat this class as a regular class and will never want a designer surface. Is there any way to override Visual Studio's default behavior?

Это было полезно?

Решение

Try adding this attribute:

[System.ComponentModel.DesignerCategory("")]
public class WebDavClient : WebClient
{
}

http://msdn.microsoft.com/en-us/library/system.componentmodel.designercategoryattribute.aspx

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top