装配是如何解决的。NET? [英] How is an assembly resolved in .NET?

查看:136
本文介绍了装配是如何解决的。NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在.NET解决程序集。我的意思是,一个完全合格的名称的组件是如何解决的。我很困惑的公钥/私钥令牌和强命名。谢谢

How are assemblies resolved in .NET. I mean, how is an assembly with a fully qualified name resolved. I am confused about the public/private key tokens and strong naming. Thanks

编辑:我也看到了有关延迟签名之类的东西。人们是否真的使用它? (有没有人实际使用延迟签名)谁产生了汇编签名的密钥。我很抱歉,如果我问太多问题。但是,我很困惑,这件事。

I have also read about delayed signing and stuff like that. Do people really use it? (Has anyone actually used delay signing) Who generates the key to sign an assembly. I am sorry if I am asking too many questions. But, I am confused about this whole thing.

推荐答案

强命名是连同公钥标记用于生产组装的完整的显示名称的( mscorlib程序,版本= 2.0.0.0,文化=中性公钥= b4778,..... )。这使我们有多个版本的同一应用程序目录内的相同组件侧由端的

Strong naming is used together with a "public key token" to produce an assembly full display name (mscorlib, version=2.0.0.0, Culture=neutral, PublicKeyToken=b4778,.....). This enables us have multiple versions of the same assembly side-by-side within the same application directory.

一个公钥标记(因此,串命名技术)还允许.NET加载器来检测是否有人篡改您的程序集的内容,因为你散发它。这是因为,当您注册你的私人令牌的程序集,编译器将生成它嵌入到一个描述你的私人令牌的公共部分程序集元数据的哈希值。然后,加载程序可以使用这个值来确定程序集是否被修改。

A public key token (and hence, string naming technique) also allows the .NET loader to detect whether anybody has tampered with your assembly contents since you distributed it. This is true because when you sign an assembly with your "private token", the compiler will generate a hash value which it embeds into the assembly metadata that describes the public portion of your "private token". The loader can then use this value to determine whether or not your assembly was modified.

关于解决集会,有一些基本的东西要考虑:

Concerning resolving assemblies, there are a few basic things to consider:

  • 探测 装载机尝试查找使用基本目录探测技术组件。这意味着,它会尝试找到 MyAssembly.dll程序(例如)在应用程序的启动目录,如果不存在,则在下面的子目录。如果探测无法找到 MyAssembly.dll程序,那么的AppDomain AssemblyResolve 事件。

  • Probing The loader attempts to locate assemblies using a basic directory "probing" technique. This means that it will try to locate "MyAssembly.dll" (for instance) in the application's startup directory, if not there, then in subdirectories below that. If probing fails to locate "MyAssembly.dll", then the AppDomain's AssemblyResolve event is fired.

机/用户/系统配置 machine.config的 user.config system.config 是存储在本地系统,可以用它来更改机,用户或系统 - 宽设置的组件解析器的行为上的配置文件。

Machine/User/System configuration The machine.config, user.config and system.config are configuration files stored locally on the system which one can use to change the behavior of the assembly resolver on a "machine", "user" or "system"-wide setting.

发布策略 我们可以用< assemblyIdentity> 在应用程序的配置文件中的XML标记(例如, MyApp.exe.config )指向解析器某个版本的组件或负载从一个不同的位置组装。

Publisher Policy One can use the "<assemblyIdentity>" XML token in your application's configuration file (for instance, "MyApp.exe.config") to point to resolver to a certain version of an assembly or to load an assembly from a different location.

自定义分辨率 办理的AppDomain AssemblyResolve 事件。引发此事件每当组件无法通过传统方法

Custom resolution Handle the "AssemblyResolve" event of the AppDomain. This event is raised whenever an assembly could not be resolved via "traditional" methods

至今为止最复杂的机制来处理AssemblyResolve事件。

By far the least complicated mechanism is to handle the "AssemblyResolve" event.

总之,解析器看起来在当前目录或全局程序集缓存,处理策略,然后终于可以自定义分辨率。

To summarize, the resolver looks in the current directory or the Global assembly cache, processes policy and then finally allows custom resolution.

这篇关于装配是如何解决的。NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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