ConstructorInfo GetCustomAttributes different implementations RRS feed

  • Question

  • In a class library that targets Windows 8.1 and Windows Phone 8.1 I have the following code, where the GetCustomAttributes returns IEnumerable<Attribute>.

    int amountOfParams = constr[x].GetCustomAttributes(true).Count();

    In my universal app I imported the library in the Windows and in the Windows Phone project if I open the class here I see that the same line returns an Object[].

    So I tried to fix it with preprocessor directives like this:

                int amountOfParams = constr[x].GetCustomAttributes(true).Length;
                int amountOfParams = constr[x].GetCustomAttributes(true).Count();

    But this doesn't work it always chooses the else, I also noticed that in VS2013 update 4 the drop down box that specifies how to view the code only lists (Miscellaneous Files).

    Is there a way to fix this problem?

    With kind regards,


    Monday, February 23, 2015 10:34 AM

All replies