ArgumentNullException after upgrade to version 5.0.30

jonyadamit's Avatar


29 Jul, 2017 04:44 AM

I have spent 3 days already trying to upgrade from version 4.3.
Already found several bugs and reported them.
My solution is very big and aspects are applied at assembly level.
Reproduction of those bugs is next to impossible because there is no way of knowing where the exception occured. (i.e what piece of code PostSharp was processing during build that made it fail)
The current exception did not occur on version 5.0.29 - I hope this helps you narrow it's reasons. Stack trace included below.
I'm still struggling with the NotifyPropertyChanged bugs - already reported about two conditions that cause InvalidOperationException but there are more conditions that cause it and it is extremely hard to pin point since, again, there is no way of knowing where the exception occurs.

As it stands PostSharp 5 is nowhere near ready for production.
At the very least please provide a way to determine where post sharp fails so I can report those bugs for you to fix.

Stack trace:

\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099: Unhandled exception(, postsharp-net40-x64-srv.exe, CLR 4.0.30319.460798, Release): System.ArgumentNullException: Value cannot be null.
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099: Parameter name: operand
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Sdk.CodeModel.InstructionWriter.EmitInstructionString(OpCodeNumber code, LiteralString operand)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Patterns.Diagnostics.Weaver.Logging.MethodContextFormatter.<>c_DisplayClass8_2.<WriteMethodContext>b_2(InstructionWriter w)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Patterns.Diagnostics.Weaver.Logging.MethodContextFormatter.WriteParameter(ITypeSignature parameterType, Action1 parameterLoader, IGenericMethodDefinition setMethod)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Patterns.Diagnostics.Weaver.Logging.MethodContextFormatter.WriteMethodContext(LoggingOptions logOptions, LogRecordKind logRecordKind, Boolean includeInParameters)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Patterns.Diagnostics.Weaver.Logging.MethodLoggingAspectTransformation.MethodLoggingTransformationInstance.Implementation.EmitWrite(InstructionWriter writer, LocalVariableSymbol recordBuilderVariable, LogRecordKind logRecordKind, LoggingOptions logOptions, LocalVariableSymbol exceptionVariable, Boolean hasExecutionTime, LocalVariableSymbol isOvertimeLocal, StateMachineTransformationContext stateMachineTransformationContext)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Patterns.Diagnostics.Weaver.Logging.LoggingAspectTransformationBase.LoggingAspectImplementationBase.EmitLog(InstructionWriter writer, InstructionBlock currentBlock, LogRecordKind logRecordKind, LocalVariableSymbol recordInfoLocal, ILocalStorage contextVariable, LocalVariableSymbol exceptionLocal, LocalVariableSymbol isOvertimeLocal, LoggingOptions logOptions, Boolean disposeContext, Boolean hasExecutionTime, StateMachineTransformationContext stateMachineTransformationContext)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Patterns.Diagnostics.Weaver.Logging.MethodLoggingAspectTransformation.MethodLoggingTransformationInstance.Implementation.EmitMessage(MethodBodyWrappingAdviseContext adviseContext, LogLevel logLevel, LogRecordKind logRecordKind, LoggingOptions logOptions)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Patterns.Diagnostics.Weaver.Logging.MethodLoggingAspectTransformation.MethodLoggingTransformationInstance.Implementation.ImplementOnSuccessAdvice(MethodBodyWrappingAdviseContext adviseContext)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at ^9rRaHg41Qg\.d.^dyR\.bHLt.ImplementOnSuccessAdvice(MethodBodyWrappingAdviseContext _0)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at ^X\.fI5RG5gOD6.InjectAdvices()
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at ^EbCRMdujK27A.^LuETqvLKzZPB(MetadataDeclaration _0, MetadataDeclaration _1, MethodSemantics _2, InstructionBlock _3, Object[] _4, CanonicalMethodMapping _5, LocalVariableSymbol _6, InstructionSequence _7, TypeDefDeclaration _8, PipelineTransversalState _9, StateMachineTransformationContext _a)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at ^PE9ycIe2cLwm.^HvVDHXOj(MetadataDeclaration _0, IDependencyTransformationInstance[] _1, PipelineTransversalState _2, MethodSemantics _3)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Sdk.AspectInfrastructure.AspectInfrastructureTask.^jwku0geZ(MetadataDeclaration _0, PipelineTransversalState _1, MethodSemantics _2, Boolean _3)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Sdk.AspectInfrastructure.AspectInfrastructureTask.^YVoDPIVQ(IMetadataDeclaration _0)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary1.^+g+TCqVg(TypeDefDeclaration _0, Func2 _1, Set1 _2)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary1.^+g+TCqVg(TypeDefDeclaration _0, Func2 _1, Set1 _2)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Sdk.AspectInfrastructure.StructuredDeclarationDictionary1.^fJqG(Func`2 _0)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Sdk.AspectInfrastructure.AspectInfrastructureTask.Execute()
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Sdk.Extensibility.Project.Execute()
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
\packages\PostSharp.5.0.30\build\PostSharp.targets(329,5): error PS0099:    at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).
  1. 1 Posted by jonyadamit on 31 Jul, 2017 07:04 PM

    jonyadamit's Avatar

    In the meantime I managed to overcome this issue. I don't know exactly which of my changes helped in this matter, but it might have something to do with me performing another uninstall of PostSharp Diagnostics and re-install.
    After converting several private fields to properties, adding Log exclude on a few other and refactoring several lambda expressions into regular methods - I am able to build my solution now.

  2. Support Staff 2 Posted by PostSharp Techn... on 01 Aug, 2017 03:40 PM

    PostSharp Technologies's Avatar


    We understand that it can be quite frustrating to deal with all these build errors while trying to upgrade to 5.0. And we are really thankful that you're taking time to report these issues to us. Currently we're focused on fixing all the outstanding issues to make 5.0 much more reliable.

    We have discovered that this particular issue happens when you apply the logging aspect to the method that returns a value tuple without element names:

                public static (int, int) SomeMethod(int x, int y)
                    return (x, y);

    The issue is filed in our bug tracker (#15319) and we're working on a fix. We'll get back to you once the fix is released.


  3. 3 Posted by jonyadamit on 02 Aug, 2017 02:12 PM

    jonyadamit's Avatar

    I'm sorry for lashing out, I really love PostSharp and I'm sure the complexity of this kind of advanced weaving is tremendous.
    Please do consider implementing some way to indicate the piece of code processed when the exception occurred (even if the problem is not within custom user aspects..).

  4. Support Staff 4 Posted by PostSharp Techn... on 07 Aug, 2017 09:35 AM

    PostSharp Technologies's Avatar


    The bug #15319 has been fixed in the current release of PostSharp 5.0.31.
    Should you need further help with this issue, don't hesitate to re-open this discussion.


  5. PostSharp Technologies closed this discussion on 07 Aug, 2017 09:35 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac