代码之家  ›  专栏  ›  技术社区  ›  Anuja Lamahewa

C#如何获取dll程序集信息?

  •  0
  • Anuja Lamahewa  · 技术社区  · 9 年前

    如果我们想获得我们可以使用的dll的版本号,

    Assembly assembly = Assembly.LoadFrom("System.Xml");
    Version ver = assembly.GetName().Version;
    

    如何获取其他信息(如AssemblyTitle、Assembly Product等)?

    using Reflecter.exe

    1 回复  |  直到 9 年前
        1
  •  1
  •   Cheng Chen    9 年前

    您可以使用

    var attribute = assembly.GetCustomAttribute<AssemblyTitleAttribute>();
    var title = attribute.Title;
    

    以获取属性。同样的解决方案 AssemblyProductAttribute .