0
我試圖從我的程序集的某些屬性中獲取值,例如各種版本屬性加上一些自定義屬性。如何在通用Windows應用程序中訪問裝配屬性?
當我嘗試訪問Assembly.GetExecutingAssembly()
時,它消失了!似乎只有一種方法,Load()
。
那麼如何訪問我的屬性值?
我試圖從我的程序集的某些屬性中獲取值,例如各種版本屬性加上一些自定義屬性。如何在通用Windows應用程序中訪問裝配屬性?
當我嘗試訪問Assembly.GetExecutingAssembly()
時,它消失了!似乎只有一種方法,Load()
。
那麼如何訪問我的屬性值?
我知道在WinRT中檢索程序集的唯一方法是通過GetTypeInfo
擴展方法。它在命名空間System.Reflection
中定義:
using System.Reflection;
...
foreach (var attribute in this.GetType().GetTypeInfo().Assembly.CustomAttributes)
{
Debug.WriteLine(attribute);
}