gpt4 book ai didi

c# - AssemblyName.ReferenceMatchesDefinition 如何工作?

转载 作者:行者123 更新时间:2023-11-30 14:43:00 24 4
gpt4 key购买 nike

给定以下代码:

  var n1 = new AssemblyName ("TestDll, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089");
var n2 = new AssemblyName ("TestDll, Version=2.0.0.2001, Culture=en-US, PublicKeyToken=ab7a5c561934e089");

Console.WriteLine (AssemblyName.ReferenceMatchesDefinition (n1, n2));
Console.WriteLine (AssemblyName.ReferenceMatchesDefinition (n2, n1));

为什么这两个检查都打印“True”?我原以为 AssemblyName.ReferenceMatchesDefinition 应该考虑程序集名称的版本、文化和公钥 token 属性的差异,不是吗?

如果不是,那么 ReferenceMatchesDefinition 做了哪些简单名称的比较没有做的事情?

最佳答案

我已经在 Microsoft Connect 上报告了这个问题, 并已确认为错误:

This is indeed a bug in the API. It has been in the product since it was introduced in 2.0 RTM. It never worked properly.

[...]

You may also consider API AppDomain.ApplyPolicy (with manual AssemblyName comparison). The API covers Framework assembly unification and binding redirects.You might also try to cover non-strong name assembly references. When PublicKeyToken is not present in the reference, only simple name match happens, the rest is ignored.

关于c# - AssemblyName.ReferenceMatchesDefinition 如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2494421/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com