.NET 中的程序集的物理位置在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2219295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 13:52:31  来源:igfitidea点击:

Where are assemblies in .NET physically located?

.netassembliesfile-structure

提问by Petras

I am a little confused about where .NET assemblies are physically located. Take good old LINQ. In my web.configfile it says:

我对 .NET 程序集的物理位置有点困惑。拿好老LINQ。在我的web.config文件中它说:

<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

This is the reference to LINQ. But where exactly is the DLL this refers to located? There isn't any path in the above and it's not in my bin folder.

这是对 LINQ 的引用。但是它所指的 DLL 究竟在哪里?上面没有任何路径,也不在我的 bin 文件夹中。

I also have what I think is a third-party assembly reference:

我也有我认为的第三方程序集参考:

<add assembly="MapInfo.CoreTypes, Version=4.0.0.483, Culture=neutral, PublicKeyToken=F548BCBA69D4B8DA" />

How can I tell where this is located on my machine if it's not in the binfolder?

如果它不在bin文件夹中,我如何知道它在我机器上的位置?

Also, if a DLL file is in the bindirectory, can I assume that it doesn't need to be referenced in web.config?

另外,如果 DLL 文件在bin目录中,我可以假设它不需要在 中引用web.config吗?

采纳答案by Chris O

Third-party assemblies might not be in the GAC, see MSDN article How the Runtime Locates Assembliesfor the set of rules. Or, try the SysInternals FILEMON.

第三方程序集可能不在GAC 中,请参阅 MSDN 文章“运行时如何定位程序集”以了解规则集。或者,尝试SysInternals FILEMON

回答by John Boker

I think they are located in the GAC, which is located in %WINDIR%\Assembly. More information is in Demystifying the .NET Global Assembly Cache(at The Code Project).

我认为他们位于GAC 中,该GAC位于%WINDIR%\Assembly. 更多信息在Demystifying the .NET Global Assembly Cache(在代码项目)。

回答by Bruce

Assembly and Fusion path probing is pretty complicated. I will say that typically .NET will resolve an assembly from one of two places:

组装和融合路径探测非常复杂。我会说通常 .NET 将从以下两个位置之一解析程序集:

  1. Either it will find it in local directory, like the current directory, a bin subdirectory, or other place specified by the Fusion assembly-binding logic, or

  2. it will find it in the global GAC store, where assemblies can be registered and looked up by name, version, and a couple other attributes.

  1. 它会在本地目录中找到它,例如当前目录、bin 子目录或 Fusion 程序集绑定逻辑指定的其他位置,或者

  2. 它将在全局 GAC 存储中找到它,在那里可以按名称、版本和其他几个属性注册和查找程序集。

To address your specific question about the 'bin' directory, if you're using ASP.NET (which I assume from your reference to web.config), then yes, you don't need to include the path - ASP.NET will take care of whatever it needs to do in order to make .NET look for assemblies in the 'bin' directory.

为了解决您关于“bin”目录的具体问题,如果您使用的是 ASP.NET(我从您web.config对为了使 .NET 在 'bin' 目录中查找程序集它需要做什么。

回答by diaz994

Some of the .Net Assemblies are located in the installation folder of .Net

一些 .Net 程序集位于 .Net 的安装文件夹中

Such as

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0

Inside there are the assemblies sitting. In the .NETFramework one level up you would find the different versions of .NET and their corresponding assemblies.

里面是集会。在 .NETFramework 上一级,您会发现不同版本的 .NET 及其相应的程序集。

回答by Mike Post

The short answer is: it depends on alot of things. The framework has its rulesfor how it loads assemblies. However, you can override this using the various config files (machine.config, etc). To find out where your assemblies actually live on a particular system, use the Assembly Binding Log Viewer. (It's part of the platform SDK. Just open up an SDK command shell and run fuslogvw.exe.)

简短的回答是:这取决于很多事情。框架有它如何加载程序集的规则。但是,您可以使用各种配置文件(machine.config 等)覆盖它。要找出您的程序集在特定系统上的实际位置,请使用程序集绑定日志查看器。(它是平台 SDK 的一部分。只需打开一个 SDK 命令外壳并运行 fuslogvw.exe。)

回答by Sharique

An assembly can be found mostly in either of the following places:

程序集主要位于以下任一位置:

  • GAC- C:\Windows\Assembly\GAC (Microsoft provided and by third-party in some cases)
  • Installation folder (most of the third-party controls)
  • GAC- C:\Windows\Assembly\GAC(Microsoft 提供,在某些情况下由第三方提供)
  • 安装文件夹(大部分第三方控件)

You can get path and other information about an assembly by right clicking on the assembly in your project references and selecting Properties.

您可以通过右键单击项目引用中的程序集并选择Properties来获取有关程序集的路径和其他信息。