22

When you double click on a class (in 'solution explorer')... if that class happens to be an .asmx.cs webservice... then you get this...

To add components to your class, drag them from the Toolbox and use the Properties window to set their properties. To create methods and events for your class, click here to switch to code view.

...it's a 'visual design surface' for webservices.

(Who actually uses that surface to write webservices?)

So what I want to know, how do I configure visual studio to never show me that design view?

Or at least, to show me the code view by default?

Leon Bambrick
  • 26,009
  • 9
  • 51
  • 75

3 Answers3

32

You can set the default editor for any given file type (.cs, .xml, .xsd, etc). To change the default editor for a given type:

  1. Right-click a file of that type in your project, and select "Open With..."
  2. Select your preferred editor. You may want "CSharp Editor".
  3. Click "Set as Default".

I don't see the behavior you see with web services, but this should work with all file types in Visual Studio.

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
  • This worked for me. Now those pesky "let's make it a Component, because Components!" classes like those deriving from ServiceBase don't open up in a useless designer. – Jeff Sharp Feb 19 '14 at 16:41
3

Add the following attribute to your class:

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

(Not sure why [System.ComponentModel.DesignerCategory("")] does not work.)

Steinar Herland
  • 1,134
  • 1
  • 9
  • 15
  • 1
    Just discovered http://stackoverflow.com/questions/567606/disable-designer-in-visual-studio which has a better discussion of this. – Steinar Herland Nov 22 '10 at 14:12
1

Add the following attribute to your class:

<System.ComponentModel.DesignerCategory("")>
Bob Sidie
  • 11
  • 1
  • 1
    I was the upvoter 'cause it looked like it would work and Andrew Borys's response. But now I've actually tried it and found it doesn't work for me in VS2k8 for a general class inherted from Component. I am yet to try it for a web service as this question is specifically about, but I'd remove my upvote if I could :-( – Mark Hurd Aug 07 '10 at 10:10