如何访问大会通用的Windows应用程序的属性? [英] How do I access Assembly Attributes in a Universal Windows App?

查看:229
本文介绍了如何访问大会通用的Windows应用程序的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的一些组件的属性获取值,例如各种版本的属性加上一些自定义属性。

I'm trying to get the values from some of my assembly's attributes, for example the various version attributes plus some custom attributes.

当我尝试访问 Assembly.GetExecutingAssembly()它不见了! System.Reflection.Assembly 似乎只有一个方法,加载()

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?

推荐答案

我知道在WinRT中检索组件的唯一方法是通过 GetTypeInfo的扩展方法。它在空间中定义的的System.Reflection

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);
        }

这篇关于如何访问大会通用的Windows应用程序的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆