如何配置Visual Studio以将代码视图用作Web服务的默认视图?
时间:2020-03-06 14:57:23 来源:igfitidea点击:
当我们双击一个类(在"解决方案资源管理器"中)时...如果该类恰好是.asmx.cs网络服务...那么我们会得到这个...
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.
...这是Web服务的"可视化设计图"。
(谁真正使用该表面编写Web服务?)
因此,我想知道的是,如何配置Visual Studio使其从不向我显示该设计视图?
还是至少要在默认情况下向我显示代码视图?
解决方案
我们可以为任何给定的文件类型(.cs,.xml,.xsd等)设置默认编辑器。要更改给定类型的默认编辑器,请执行以下操作:
- 右键单击项目中该类型的文件,然后选择"打开方式..."
- 选择我们喜欢的编辑器。我们可能需要" CSharp编辑器"。
- 单击"设置为默认"。
我看不到我们在Web服务中看到的行为,但这应该适用于Visual Studio中的所有文件类型。
将以下属性添加到班级:
<System.ComponentModel.DesignerCategory("")>
将以下属性添加到班级:
[System.ComponentModel.DesignerCategory("Code")]
(不确定为什么[System.ComponentModel.DesignerCategory("")]无法正常工作。)