当我尝试从Visual Studio 2015内部编译时,我收到以下错误跟踪。还有其他人经历过这个吗?
Error Unhandled exception (4.3.20.0, postsharp-net40-x86-srv.exe, CLR 4.0.30319.394271, Release): System.NullReferenceException: Object reference not set to an instance of an object.
at PostSharp.Sdk.CodeModel.GenericMap.GetGenericParameter(GenericParameterKind kind, Int32 ordinal)
at PostSharp.Sdk.CodeModel.TypeSignatures.GenericParameterTypeSignature.MapGenericArguments(GenericMap genericMap)
at PostSharp.Sdk.CodeModel.MethodDefDeclaration.WriteReflectionName(StringBuilder stringBuilder, ReflectionNameOptions options, NameMapper mapper)
at PostSharp.Sdk.CodeModel.WriteReflectionNameExtensions.GetDisplayName(IWriteReflectionName declaration)
at PostSharp.Sdk.Extensibility.Licensing.LocalLicenseManager.^BLnBYDPkLE/l(MetadataDeclaration _0, TypeDefDeclaration _1, List`1 _2, List`1 _3, ^hjDNKkMra\+ry _4)
at PostSharp.Sdk.AspectWeaver.AspectWeaver.^Rb+2eJKK(MetadataDeclaration _0)
at PostSharp.Sdk.AspectWeaver.AspectWeaverInstance.ProvideAdviceTransformations(AspectWeaverTransformationAdder adder)
at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.^5t5Tu4zL(AspectWeaverInstance _0)
at PostSharp.Sdk.AspectWeaver.AspectWeaverTask.^vPCloP06(IMetadataDeclaration _0, AspectWeaverInstance _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).
编辑:在尝试为此制作示例项目时,我能够找出原因。我们将OnMethodBoundary方面(内部日志记录方面)应用于具有public static implicit operator T(Editable<T> item)
的类型。当我告诉PostSharp排除这种方法时,问题就消失了。
因此,要重现它,请在使用Express许可证时将OnMethodBoundary应用于通用隐式运算符。
[ExceptionLoggerAspect]
class Challenged<T>
{
public T Value { get; set; }
public static implicit operator T(Challenged<T> item)
{
return item.Value;
}
}
答案 0 :(得分:1)
我最终使用的解决方法是在一般类型的隐式运算符上使用AttributeExclude = true,我们的OnMethodBoundaryAspect正在进行多播。
[ErrorLoggingAspect(AttributeExclude = true)]
public static implicit operator T(Editable<T> item)
{
...
}