Possible to inherit from WebClient without my code being a "design time component"?
c#, components, visual-studio, visual-studio-2012, webclient
Solution
The problem is that Visual Studio will automatically add
<SubType>Component</SubType>
in your .csproj file as soon as you inherit from WebClient. Even if you try to remove this, Visual Studio adds it again when you reopen the project.
A solution is to add the following attribute to your class.
[System.ComponentModel.DesignerCategory("Code")]
Problem
I have a piece of code like this: ``` public class NoFollowWebClient : WebClient { protected override WebRequest GetWebRequest(Uri address) { var request = (HttpWebRequest)base.GetWebRequest(address); request.AllowAutoRedirect = false; return request; } } ``` Whenever I add this to a .cs file though, Visual Studio 2012, in it's infinite wisdom, converts my C# source file to a "design time component". So, when I double click on the file now, instead of seeing my C# code, I see "To add components to your class, drag them from the Toolbox and use the Properties window to set their properties". I know I can right click and do "view code", but that's extremely annoying. Is there anyway to force Visual Studio to not assume I'm making a component or that I care about their stupid visual designer that serves no purpose for my class?