可移植类库配置文件78缺少与属性相关的方法/属性

在我的PCL核心项目(WP8,Android,iOS,Xamarin,MvvmCross)中,我使用自定义属性。 Type.GetCustomAttributes()扩展方法让我检查使用的属性。

使用PCL Profile104这很有效。 但是因为我想使用async / await,我需要使用PCL Profile78(和.NET 4.5)

问题:看起来GetCustomAttributes()和Attributes属性在Profile78中不可用。 为什么??

注意:我正在研究解决方法,方法是创建一个PCL Profile 104类库并包装GetCustomAttributes(),然后从我的PCL Profile78库中引用该库。 但是似乎不支持扩展方法……

示例代码:

public Pcl78Class() { Type t = this.GetType(); var attributes = t.Attributes; var customAttributes = t.GetCustomAttributes(true); // another weird thing: Why is VS CodeCompletion telling me it knows CustomAttributeExtensions class and methods? //System.Reflection.CustomAttributeExtensions.GetCustomAttributes(t); } 

在此处输入图像描述

问题:看起来GetCustomAttributes()和Attributes属性在Profile78中不可用。 为什么??

Profile78包括对Windows Store 8的支持 (如我的博客中所述),而Windows Store可以更有效地实现基于Type的reflection 。 本质上,您只需要调用Type.GetTypeInfo来获取TypeInfo ,从那里它应该非常简单。