简体   繁体   English

为什么System.Configuration程序集默认不包含在新项目中?

[英]Why is the System.Configuration assembly not included in new projects by default?

Small pet peev. 小宠物peev。 When creating new visual studio projects is there any way to include the system.configuration assembly by default? 在创建新的visual studio项目时,有没有办法在默认情况下包含system.configuration程序集? Almost all of my new projects will need access to the configuration AppSettings. 几乎所有我的新项目都需要访问配置AppSettings。

I know it's not much effort to do Project > Add reference, but I imagine that this is a very very common thing for most people and wondered why it's not included by default? 我知道做项目>添加引用不是很费力,但我想这对大多数人来说是一个非常普遍的事情,并且想知道为什么默认情况下不包括它?

You can do this by creating your own project template that includes a reference to System.Configuration.dll. 您可以通过创建自己的项目模板来执行此操作,该模板包含对System.Configuration.dll的引用。 Here is a link that has a walk through on how to do this 这是一个链接,了解如何执行此操作

As to why the behavior is what it is today, I don't think you'll find a solid answer about that. 至于为什么这种行为就像现在这样,我认为你不会找到一个可靠的答案。

You can customize your own template: 您可以自定义自己的模板:

http://msdn.microsoft.com/en-us/magazine/cc188697.aspx#S3 http://msdn.microsoft.com/en-us/magazine/cc188697.aspx#S3

Note that this link is old, but I don't imagine things have changed much. 请注意,此链接很旧,但我不认为事情发生了很大变化。

EDIT: you can follow a similar methodology for file templating as well, ie you can customize the standard c# class file layout, user/custom control templates, etc. I have used this to customize which using statements are included by default, and to insert default comment blocks at the top of the file. 编辑:您也可以按照类似的文件模板方法,即您可以自定义标准的c#类文件布局,用户/自定义控件模板等。我已经使用它来自定义默认包含哪些using语句,并插入文件顶部的默认注释块。

EDIT: this assembly is included by default in VS 2010 web applications, so perhaps it was just an oversight, or someone was overzealous in their attempts to be minimalist. 编辑:该组件默认情况下在VS 2010 Web应用程序在内,所以也许这只是一个疏忽,或有人在过分热心在他们的企图是极简主义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM