简体   繁体   English

反射和强命名程序集

[英]Reflection and strong named assemblies

  1. I have created a test project whose output will be strong named assembly. 我创建了一个测试项目,其输出将为强命名程序集。 I have specified the SNK file name in the 'project -> properties - > Signing' section so that assembly will be strong named. 我在“项目->属性->签名”部分中指定了SNK文件名,以便程序集具有强名称。 I added reference of the assembly which is NOT signed or strong named. 我添加了未签名或强命名的程序集的引用。 I was expecting that my project will not at all build since it's referencing unsigned assembly. 我期望我的项目完全不会生成,因为它引用的是未签名的程序集。 However, it built and i could install the assembly in GAC too! 但是,它已经建成,我也可以在GAC中安装该组件! Why is it so? 为什么会这样呢? (I'm using .NEt 4.0 and it's gacutil.exe) Note: I have ensured that the assembly which is being referenced is NOT strong named. (我使用的是.NEt 4.0,它是gacutil.exe)注意:我确保所引用的程序集不是强命名的。

  2. Can i programatically load the 'unsigned' (ie non-strong named) assembly in my program whose output is going to be strong named assembly? 我可以在我的程序中以编程方式加载“ unsigned”(即非强命名)程序集,其输出将成为强命名程序集吗? If yes, why is it allowed to do so when on the other hand, .NET don't allow to add reference to unsigned assemblies? 如果是,为什么允许这样做,而.NET不允许添加对未签名程序集的引用?

  3. If I have multiple versions of the same assembly in GAC. 如果我在GAC中具有同一程序集的多个版本。 In my configuration file, If I specify just the name of the assembly, which version will be loaded from GAC? 在我的配置文件中,如果仅指定程序集的名称,将从GAC加载哪个版本? Will it be latest version everytime? 每次都会是最新版本吗? Which API will be useful? 哪个API有用? I found many methods marked 'deprecated' in Assembly class. 我在Assembly类中发现了许多标记为“不赞成使用”的方法。

You can reference the unsigned assembly in VS.Net from a signed assembly. 您可以从已签名的程序集中引用VS.Net中的未签名的程序集。 But if you call anything from the signed to the unsigned, the build will fail. 但是,如果您调用从有符号到无符号的任何内容,构建都将失败。

  1. There is no problem in signed assembly referencing an unsigned assembly. 签名的程序集引用未签名的程序集没有问题。 It can be done and signed assembly can be GACed. 可以完成,可以对GACed签名程序集。

  2. Yes, you can load. 是的,您可以加载。

  3. How can you specify assembly by just name ? 如何仅通过名称指定装配? There is only one API LoadWithPartialName and thats deprecated for many reasons. 只有一个API LoadWithPartialName,并且由于许多原因而已弃用。 You need version, culture and public key token to uniquely identify assembly. 您需要版本,区域性和公共密钥令牌来唯一标识程序集。

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

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