相关疑难解决方法(0)

可移植类库配置文件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);
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

c# xamarin.ios xamarin.android portable-class-library xamarin

6
推荐指数
1
解决办法
2912
查看次数