"Incorrect ordering of advices on method" with PostSharp 5.0.28

ff's Avatar


13 Jul, 2017 11:55 AM

I have an issue with with two different aspects I'd like to use.
First of all I try to use [Log] attribute on a class. And second I'd like to add a [Required] on two parameters of a method in the same class.
The full error message is:
error LA0145: Incorrect ordering of advices on method "RestClient.File.CopyAsync(System.String, System.String, System.Boolean)". Advice "PostSharp.Patterns.Contracts.RequiredAttribute: Validates the value passed to parameter 'destFileName'" cannot be after advice "PostSharp.Patterns.Diagnostics.LogAttribute: Transformed by state-machine-aware advice." because state-machine-aware advices must be positioned after all other advices.

I tried to reproduce the error with a simple ConsoleApp without any success. In this simple version everything works fine.

Is there any solution for this problem?

Best regards

  1. Support Staff 1 Posted by PostSharp Techn... on 14 Jul, 2017 01:39 PM

    PostSharp Technologies's Avatar


    I can confirm that we have reproduced the issue. It is caused by the Logging aspect and Code Contracts not being properly ordered. The bug is filed in our bug tracker (#15260) and we'll get back to you once it's fixed.

    In the meantime you should be able to work around the issue by specifying the ordering manually in your project like this:

    [assembly:AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, StandardRoles.Validation, TargetType = typeof(LogAttribute))]


  2. Support Staff 2 Posted by PostSharp Techn... on 21 Jul, 2017 12:20 PM

    PostSharp Technologies's Avatar


    the issue was fixed in PostSharp 5.0.29.

    Best regards

  3. PostSharp Technologies closed this discussion on 21 Jul, 2017 12:55 PM.

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