简体   繁体   English

如何在通用Windows应用程序中访问程序集属性?

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

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! 当我尝试访问Assembly.GetExecutingAssembly()它消失了! System.Reflection.Assembly seems to have only one method, Load() . System.Reflection.Assembly似乎只有一种方法Load()

So how do I access my attribute values? 那么,如何访问我的属性值?

The only way I know in WinRT to retrieve the assembly is through the GetTypeInfo extension method. 我在WinRT中知道的唯一检索程序集的方法是通过GetTypeInfo扩展方法。 It's defined in the namespace System.Reflection : 它在名称空间System.Reflection定义:

using System.Reflection;

...

        foreach (var attribute in this.GetType().GetTypeInfo().Assembly.CustomAttributes)
        {
            Debug.WriteLine(attribute);
        }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查Windows Universal应用程序中是否存在文件 - How do I check if a file exists in a Windows Universal App 如何在c#的通用Windows应用程序中包含计时器 - How do I include a timer in a universal windows app with c# 如何在Windows Universal Apps中访问App.Current属性 - How to access App.Current properties in Windows Universal Apps 如何在Windows Universal App中的“共享”项目下读取项目文件? - How do I read project files under the Shared project in a Windows Universal App? 如何在Windows Phone 8.1 Universal App中获取街道地址的地理位置? - How do I get Geolocation of a street address in Windows Phone 8.1 Universal App? 如何从控制台应用程序连接到Windows Universal App StreamSocket? - How do I connect to a Windows Universal App StreamSocket from a Console Application? 如何安装 SQLite 以在面向 UAP v10 的通用 Windows 应用程序中使用 - How do I install SQLite for use in a Universal Windows App targetting UAP v10 如何在 UWP(通用 Windows 编程)应用程序中进行简单的用户登录 - How to do simple user login in UWP (Universal Windows Programming) app Windows 10 通用应用程序文件/目录访问 - Windows 10 Universal App File/Directory Access 在同一解决方案中,我如何与通用的.Net 4.5应用程序实时通信通用Windows应用程序。 IPC? - How do I real time communicate a Universal Windows App with a older .Net 4.5 app in the same solution. IPC?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM