【问题标题】:Why my UWP app can't call to Type.GetProperties method?为什么我的 UWP 应用无法调用 Type.GetProperties 方法?
【发布时间】:2016-02-17 19:22:08
【问题描述】:

我需要在我的 UWP 平台中访问 Type.GetProperties,但我的 Type 类滞后于该方法。

在我看来,这是因为我们在 UWP 中有子集方法,但在尝试查找信息时,我发现了这个:Type.GetProperties() doesn't work in Release,因此该方法确实存在于 UWP 中。

如果我去类型的定义,第一行是这样的:

#region Assembly System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:\Users\JoséÁngel\.nuget\packages\System.Runtime\4.0.20\ref\dotnet\System.Runtime.dll
#endregion

也许我的 nuget 配置有问题?

项目的条件编译符号为:

NETFX_CORE;WINDOWS_UWP;CODE_ANALYSIS

我尝试了使用和不使用“使用 .NET Native 工具链编译”选项。

目标是通用 Windows

目标版本是:Windows 10 (10.0; Build 10586) 最低版本为:Windows 10 (10.0; Build 10240)

但我也尝试过使用最低版本:Windows 10 (10.0; Build 10586)

在 NuGET 中,该项目只有 Microsoft.NETCore.UniversalWindowsPlatform v5.0.0

【问题讨论】:

    标签: c# reflection win-universal-app


    【解决方案1】:

    按照链接问题的答案中的说明将您的类型添加到 .net 原生动态列表中,然后使用 *yourthing*.GetType().GetTypeInfo().DeclaredProperties

    https://msdn.microsoft.com/en-us/library/system.reflection.introspectionextensions.gettypeinfo%28v=vs.110%29.aspx https://msdn.microsoft.com/en-us/library/system.reflection.typeinfo%28v=vs.110%29.aspx

    有关更多信息,请参阅本文中的反射部分:https://blogs.msdn.microsoft.com/dotnet/2016/02/10/porting-to-net-core/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-14
      • 2013-04-17
      • 2013-03-31
      • 2015-08-01
      • 2013-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多