c# - .net-native enum.GetValues 麻烦

标签 c# windows-10 uwp .net-native

我正在尝试让我的应用程序(适用于 Windows 10)在 .NET native 下运行。

我遇到了以下问题:Enum.GetValues 在运行时失败,缺少元数据。我设法简化了这个问题的测试用例(在现实生活中我的代码看起来不同)。在可移植图书馆我有:

public enum enumValues
{        
    A1,     
    B1,        
    C1,
}

public class fff
{
    public static object GetClass2Value()
    {
        return enumValues.B1;
    }
}

在我的通用 Windows 应用程序中,我调用了以下代码:

Array aaa = Enum.GetValues(fff.GetClass2Value().GetType());

我收到以下异常:

Additional information: 'enumlibportable.enumValues[]' is missing metadata.

问题是我不知道要向 Default.rd.xml 添加什么。我尝试使用 Microsoft 工具 http://go.microsoft.com/fwlink/?LinkID=392859 添加不同的 rd 字符串(枚举子类型、enumValues 类、enumValues[] 等) , 但没有运气。

更新: 我知道下面的代码适用于我的测试用例 Enum.GetValues(typeof(enumValue)),但我不能在我的真实项目中使用它,因为我不知道确切的枚举类型我的真实项目。

最佳答案

这对我来说没有意义,但以下 RD 字符串适用于我的测试用例:

<Type Name="enumlibportable.enumValues[]" Browse="Required All"/>

关于c# - .net-native enum.GetValues 麻烦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32452274/

相关文章:

C# 如何创建一个调用另一个泛型方法的委托(delegate)的方法

c++ - Windows 7/10 中的 Winlogon 屏幕捕获

c - printf 没有按预期工作。有人可以解释输出吗?

c# - 如何更改 UWP 的复选框背景?

c# - 在 Windows 10 的 GridView 中检测 ScrollViewer 的 ViewChanged 事件

windows - 如何在 UWP 上的 Xamarin.Forms WebView 中启用 WebGL?

c# - 为 HTTP 监听器设置 'Access-Control-Allow-Origin'

c# - 'base' 和 'this' 在引用父对象字段、属性或方法时有区别吗?

c# - 修改 languageDefinitions.config 文件

c++ - 管道在 Windows 7 上的 WinApi 中不起作用,但在 Windows 10 上起作用