如何在通用Windows应用程序中访问程序集属性
本文关键字:访问 程序集 属性 应用程序 Windows | 更新日期: 2023-09-27 18:21:06
我正试图从程序集的一些属性中获取值,例如各种版本属性加上一些自定义属性。
当我尝试访问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);
}