以下代码在编译期间引发异常:
[PSerializable]
public class MyAspectAttribute : OnMethodBoundaryAspect {
}
[MyAspect]
Task<object> Method1<T>() {
throw new NotImplementedException();
}
我试图找到重现此问题的最小操作集,这里是:
- 创建空的 Windows Phone 7.1 项目
- 向其中添加 Microsoft.Bcl 和 PostSharp NuGet 包
- 创建简单的空方面(如下所示)
- 添加从 System.Threading.Tasks.dll 返回任何类型的通用方法
完整的异常文本:
Unhandled exception (3.0.31.0, 32 bit, CLR 4.5, Release): PostSharp.Sdk.CodeModel.BindingException: The type 'System.Threading.Tasks.Task`1' does not exist in the target platform.
at PostSharp.Sdk.CodeModel.Binding.ReflectionBindingManager.GetReferenceAssembly(IAssemblyName assemblyName, String typeName, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.Binding.ReflectionBindingManager.ResolveAssembly(Type type, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindType(Type reflectionType, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindType(Type reflectionType, BindingOptions bindingOptions)
at ^XJbqCOExOmCj.^i8LBKh1N(ModuleDeclaration _0, MethodBase _1, BindingOptions _2)
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindMethod(MethodBase reflectionMethod, BindingOptions bindingOptions)
at ^XJbqCOExOmCj.^4IrPP9eT(Object _0, IMethod _1, Type[] _2, Type[] _3, BindingOptions _4)
at PostSharp.Sdk.CodeModel.MethodDefDeclaration.^NqB3CEvX(BindingOptions _0)
at ^Mzw3\.bgGgRlJ.^cCM832sT[??0](Object _0, BindingOptions _1, ^d1u4kZd5aJLe _2)
at PostSharp.Sdk.CodeModel.MethodDefDeclaration.GetSystemMethod(Type[] genericTypeArguments, Type[] genericMethodArguments, BindingOptions bindingOptions)
at PostSharp.Sdk.CodeModel.MethodDefDeclaration.^xHA5o+hH(Type[] _0, Type[] _1, BindingOptions _2)
at PostSharp.Sdk.CodeModel.MetadataDeclaration.^UDRJYqgBJZ7t(Type[] _0, Type[] _1, BindingOptions _2)
at PostSharp.Sdk.AspectWeaver.AspectWeaverInstance..ctor(AspectWeaver aspectWeaver, AspectInstanceInfo aspectInstanceInfo)
at PostSharp.Sdk.AspectWeaver.AspectWeavers.MethodLevelAspectWeaverInstance..ctor(MethodLevelAspectWeaver aspectWeaver, AspectInstanceInfo aspectInstanceInfo)
at ^wy1eTA/ccvw/.CreateAspectWeaverInstance(AspectInstanceInfo _0)
at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.^lp9i7ZhC(InstructionWriter _0, AspectInstanceInfo _1, StructuredDeclarationDictionary`1 _2)
at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.^Vyy/rF6E.^Qs9Uz9QP(IMetadataDeclaration _0, AspectInstanceInfo _1)
at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^lNgKC+Z4(IMetadataDeclaration _0, Func`3 _1)
at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^RdBVqi\.M.^8/pSq47Q(IMetadataDeclaration _0)
at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^d+wOzSPF(IMetadataDeclaration _0, Func`2 _1)
at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^+g+TCqVg(TypeDefDeclaration _0, Func`2 _1, Set`1 _2)
at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^fJqG(Func`2 _0)
at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary`1.^fJqG(Func`3 _0)
at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.Execute()
at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
at PostSharp.Sdk.Extensibility.Project.Execute()
at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)