反射和强命名程序集

发布于 2024-10-05 23:24:30 字数 484 浏览 0 评论 0原文

  1. 我创建了一个测试项目,其输出将是强命名程序集。我已经在'project ->; 中指定了SNK文件名属性->签名'部分,以便程序集被强命名。 我添加了未签名或强命名的程序集的引用。我预计我的项目根本不会构建,因为它引用了未签名的程序集。然而,它已经构建完成,我也可以在 GAC 中安装该组件!为什么会这样呢? (我使用的是 .NEt 4.0,它是 gacutil.exe) 注意:我已确保所引用的程序集不是强命名的。

  2. 我可以在程序中以编程方式加载“无符号”(即非强命名)程序集,其输出将是强命名程序集吗?如果是,为什么允许这样做,而另一方面,.NET 不允许添加对未签名程序集的引用?

  3. 如果我在 GAC 中有同一程序集的多个版本。在我的配置文件中,如果我仅指定程序集的名称,将从 GAC 加载哪个版本?每次都是最新版本吗?哪个 API 会有用?我在 Assembly 类中发现了许多标记为“已弃用”的方法。

  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.
    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! 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.

  2. Can i programatically load the 'unsigned' (i.e. non-strong named) assembly in my program whose output is going to be strong named assembly? If yes, why is it allowed to do so when on the other hand, .NET don't allow to add reference to unsigned assemblies?

  3. If I have multiple versions of the same assembly in GAC. In my configuration file, If I specify just the name of the assembly, which version will be loaded from GAC? Will it be latest version everytime? Which API will be useful? I found many methods marked 'deprecated' in Assembly class.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

软甜啾 2024-10-12 23:24:30

您可以从已签名的程序集引用 VS.Net 中未签名的程序集。但是,如果您调用从已签名到未签名的任何内容,构建将会失败。

You can reference the unsigned assembly in VS.Net from a signed assembly. But if you call anything from the signed to the unsigned, the build will fail.

夜访吸血鬼 2024-10-12 23:24:30
  1. 签名的程序集引用未签名的程序集没有问题。这是可以完成的,并且签名的程序集可以进行 GAC 处理。

  2. 是的,您可以加载。

  3. 如何仅通过名称来指定程序集?只有一个 API LoadWithPartialName,但由于多种原因已被弃用。您需要版本、区域性和公钥标记来唯一标识程序集。

  1. There is no problem in signed assembly referencing an unsigned assembly. It can be done and signed assembly can be 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. You need version, culture and public key token to uniquely identify assembly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文