繁体   English   中英

PostSharp:在Windows Phone 7项目中与Microsoft.Bcl一起使用时,BindingException

[英]PostSharp: BindingException when using with Microsoft.Bcl in Windows Phone 7 project

以下代码在编译期间引发异常:

[PSerializable]
public class MyAspectAttribute : OnMethodBoundaryAspect {
}

[MyAspect]
Task<object> Method1<T>() {
    throw new NotImplementedException();
}

我试图找到最小的动作集来重现此问题,这里是:

  1. 创建空的Windows Phone 7.1项目
  2. 向其中添加Microsoft.Bcl和PostSharp NuGet软件包
  3. 创建简单的空白区域(如下所示)
  4. 在某处添加通用方法,该方法从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)

这是PostSharp 3.0.31中的设计例外因为将需要显式支持Microsoft.Bcl 我在http://postsharp.uservoice.com/forums/4949-general/suggestions/4225929-support-for-microsoft-bcl上添加了功能请求。

-gael

暂无
暂无

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

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