[英]Single assemby in using statement
I'm working on app which uses a lot of external assemblies (newtonsoft.dll, Yahoo Yui compressor.dll, fleck.dll etc). 我正在开发使用大量外部程序集的应用程序(newtonsoft.dll,Yahoo Yui compressor.dll,fleck.dll等)。 In each c# file I need to add using statement with all those assemblies.
在每个C#文件中,我需要为所有这些程序集添加using语句。 Is it possible to create my own assembly (ie LIBRARY.dll) containing all the dll's and refer only to this in all c# files?
是否可以创建包含所有dll的我自己的程序集(即LIBRARY.dll),并在所有c#文件中仅引用该程序集?
No. Firstly, using
directives refer to namespaces , not assemblies (assembly references are defined at the project level). 否。首先,
using
伪指令是指名称空间 ,而不是程序集(程序集引用是在项目级别定义的)。 Secondly: you almost certainly don't actually need all of them in every file. 其次:你几乎可以肯定,实际上并不需要所有的人都在每一个文件。 But: you can create a new-file-template with the ones you are likely to need.
但是:您可以使用可能需要的模板创建一个新文件模板。 But frankly it is usually easier to either copy/paste them, or just add them when they are needed.
但坦率地说,通常更容易复制/粘贴它们,或仅在需要时添加它们。 In the IDE, this is as simple as pressing ctrl + .
在IDE中,这就像按ctrl +一样简单。 , ret after a type name that doesn't resolve... so
MySpecialType
ctrl + . ,这不能解决一个类型名字......所以以后RET
MySpecialType
CTRL +。 , ret should add the missing using
directive to resolve MySpecialType
. , ret应该添加缺少的
using
指令来解析MySpecialType
。
using
does not refer to assembly, but to namespace. using
不是指汇编,而是指名称空间。 So the answer is "no"... 所以答案是“不” ...
using System; // you are using items in the System namespace
using System.IO; // you are using items in the System.IO namespace
否。需要将各个类型的用法解析为定义它们的名称空间。因此,您仍然需要在使用中包括解析路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.