gpt4 book ai didi

c# - 为什么我的 UWP 应用无法调用 Type.GetProperties 方法?

转载 作者:太空宇宙 更新时间:2023-11-03 19:01:17 25 4
gpt4 key购买 nike

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

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

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

#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

最佳答案

如链接问题的答案中所述,将您的类型添加到 .net native 动态列表,然后使用 *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

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

关于c# - 为什么我的 UWP 应用无法调用 Type.GetProperties 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35449747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com