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

流过昼夜 提交于 2019-12-11 20:11:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!