如何在通用 Windows 应用程序中访问程序集属性?

How do I access Assembly Attributes in a Universal Windows App?

我正在尝试从我的程序集的一些属性中获取值,例如各种版本属性和一些自定义属性。

当我尝试访问 Assembly.GetExecutingAssembly() 时,它不见了! System.Reflection.Assembly好像只有一种方法,Load()

那么如何访问我的属性值?

我知道在 WinRT 中检索程序集的唯一方法是通过 GetTypeInfo 扩展方法。它在命名空间 System.Reflection:

中定义
using System.Reflection;

...

        foreach (var attribute in this.GetType().GetTypeInfo().Assembly.CustomAttributes)
        {
            Debug.WriteLine(attribute);
        }