C#参考列表 [英] List of C# References

查看:69
本文介绍了C#参考列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,



我正在研究一个项目,我需要一个每个c#参考的列表。一个例子是System,System.Linq,System.Text等。我需要它们的完整列表。不要问问题......



谢谢!

hey guys,

i am working on a project and i need a list of every c# reference. an example would be System, System.Linq, System.Text, etc. i need the full list of them. don''t ask questions...

thanks!

推荐答案

没有这样的事情C#参考。像你这样的编程语言作家应该能够理解这些基本的东西。



我假设你的意思是如何在给定一个程序集时弄清楚它引用了哪些程序集。另一方面,它可能是实际加载的程序集。



这是如何获取引用的程序集:http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getreferencedassemblies.aspx [ ^ ] 。



这是另一种给出不同结果的方法,加载程序集:http://msdn.microsoft.com/en-us/library/system.appdomain.getassemblies.aspx [ ^ ]。



使用第二种方法,您可以在pr的运行时使用所有应用程序域ocess和merge加载的程序集。



那么,为什么这两种方法会产生不同的结果呢?问题是:当您加载程序集时,您可以引用更多它们然后您实际需要。看起来实际上未使用的引用程序集由CLR优化:如果使用第二种方法,您可能会发现某些程序集实际上并未使用。另一个原因是:您可以在运行时使用 System.Reflection.Assembly 的相应方法之一加载程序集。从这时起,一些新的程序集将显示为在您执行它的应用程序域中加载,但不必引用此类​​程序集。







此外,您的问题表明您混淆了程序集和命名空间。例如,System不能引用,因为这不是程序集。如果您只使用.NET FCL程序集,您将看到两个不同的程序集声明类型,然后命名空间System。此外,您可以创建自己的程序集并在同一名称空间下声明类型,它将完全有效,一些第三方产品就是这样。一个程序集可以在两个或多个不同(相关或不相关)的名称空间下声明类型。



这些东西只是彼此正交。实际上,当代码编译为CIL时,名称空间不存在任何实际对象。它们不再是完全限定类型名称的一些子集。声明它们的类型和程序集,以及模块 - 这是实际存在的。并且只能引用程序集,而不能引用命名空间。



您只需要了解这些概念,然后再继续。



-SA
There is no such thing as "C# reference". A "a programming language writer" like you should be able to understand such basic things.

I assume you mean how to figure out, given an assembly, which assemblies it references. From the other hand, it could be the set of actually loaded assemblies.

This is how to get referenced assemblies: http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getreferencedassemblies.aspx[^].

This is another method giving somewhat different results, getting loaded assemblies: http://msdn.microsoft.com/en-us/library/system.appdomain.getassemblies.aspx[^].

With second method, you can take all Application Domains during runtime of your process and merge loaded assemblies.

So, why these two methods give different results? The thing is: when you load assemblies, you can reference more of them then you actually need. It looks like actually unused referenced assemblies are optimized out by the CLR: if you use the second method, you may find that some of your assemblies are not actually used. Another reason is this: you can load assembly during runtime, using one of corresponding methods of System.Reflection.Assembly. From this moment, some new assembly will appear as loaded in the Application Domain where you did it, but such assembly does not have to be referenced.



Also, you question suggests that you confuse assemblies and namespaces. For example, "System" cannot be "referenced", because this is not an assembly. If you take just .NET FCL assemblies, you will see that two different assemblies declare types under then namespace "System". Moreover, you can create your own assembly and declare types under the same namespace, and it will be perfectly valid, some 3rd-party products are like that. And one assembly can declare types under two or more different (related or unrelated) namespaces.

Those things are just orthogonal to each other. In fact, namespaces do not exist as any actual objects when the code is compiled to CIL. They are no more but some subsets of fully-qualified type names. The type and the assemblies declaring them, as well as modules — this is what actually exist. And only assemblies can be referenced, not namespaces.

You just need to read about those concepts, before you can move forward.

—SA


首先,打开你的工作室。然后右键单击references文件夹并选择Add Reference ...。选择.NET选项卡,然后记下您在GAC中安装的所有内容。
First, open your studio. Then right click on the references folder and select "Add Reference...". Select the .NET tab, then write down everything that you see that''s installed in the GAC.


您实际上并不是指C#引用,您的意思是.NET参考 [ ^ ]。
You don''t actually mean C# references, you mean .NET references[^].


这篇关于C#参考列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆