问题
I'm trying to get the values from some of my assembly's attributes, for example the various version attributes plus some custom attributes.
When I try to access Assembly.GetExecutingAssembly() it's gone! System.Reflection.Assembly seems to have only one method, Load().
So how do I access my attribute values?
回答1:
The only way I know in WinRT to retrieve the assembly is through the GetTypeInfo extension method. It's defined in the namespace System.Reflection:
using System.Reflection;
...
foreach (var attribute in this.GetType().GetTypeInfo().Assembly.CustomAttributes)
{
Debug.WriteLine(attribute);
}
来源:https://stackoverflow.com/questions/33589684/how-do-i-access-assembly-attributes-in-a-universal-windows-app