简体   繁体   English

.net-native枚举.GetValues问题

[英].net-native enum.GetValues trouble

I'm trying to make my app (for Windows 10) working under .NET native. 我试图使我的应用程序(适用于Windows 10)在.NET本机下运行。

I got stuck with the following issue: Enum.GetValues fails at runtime with metadata is missing. 我遇到了以下问题: Enum.GetValues在运行时失败,缺少元数据。 I managed to simplify test case for this problem (in real life my code looks different). 我设法简化了此问题的测试用例(在现实生活中,我的代码看起来有所不同)。 In portable library I have: 在便携式库中,我有:

public enum enumValues
{        
    A1,     
    B1,        
    C1,
}

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

In my Universal Windows app I call the following code: 在我的通用Windows应用程序中,我调用以下代码:

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

I receive the following exception: 我收到以下异常:

Additional information: 'enumlibportable.enumValues[]' is missing metadata. 附加信息:“ enumlibportable.enumValues []”缺少元数据。

The problem is that I have no idea what to add to Default.rd.xml. 问题是我不知道要添加到Default.rd.xml中的内容。 I've tried to add different rd strings (enum subtype, enumValues class, enumValues[] etc.) using microsoft tool http://go.microsoft.com/fwlink/?LinkID=392859 , but had no luck. 我尝试使用Microsoft工具http://go.microsoft.com/fwlink/?LinkID=392859 ,添加其他rd字符串(枚举子类型,enumValues类,enumValues []等),但是没有运气。

UPDATE : I know that the following code will work for my testcase Enum.GetValues(typeof(enumValue)) , but I can't use it in my real project since I don't know the exact enum type in my real project. 更新 :我知道以下代码将适用于我的测试用例Enum.GetValues(typeof(enumValue)) ,但是由于我不知道实际项目中的确切枚举类型,因此无法在实际项目中使用它。

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

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

也许你可以尝试这可能会帮助你

Array aaa = (enumValues) Enum.Parse(typeof(enumValues), fff.GetClass2Value());

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM