Issue when using logging without attributes

Esben Bach's Avatar

Esben Bach

31 Aug, 2017 06:50 AM

I have a project that references a library (said library is instrumented with quite a few Log attributes). The project initialises the postsharp logging backend, and everything is fine.
Now i added a "custom" logging entry in the project as follows:

public class OrderEventHandler
     private static Logger logger = Logger.GetLogger();
     public void MyHandlingMethod()
            logger.Write(LogLevel.Warning, "Something bad happened");
Now it compiles with no issues, but runtime (and from my unit tests), i get the following exception:
Message: System.TypeInitializationException : The type initializer for 'Infosoft.S4.Orders.Service.OrderEventHandler' threw an exception.
---- System.InvalidOperationException : The current assembly has not been enhanced by PostSharp Diagnostics. Use the GetLogger(string,Type) overload or add at least a [Log] aspect to the current assembly.

Adding a "Log" attribute ANYWHERE in the project fixes the issue, but its sort of not what I want - im on postsharp 5.0.31 by the way.

  1. Support Staff 1 Posted by PostSharp Techn... on 31 Aug, 2017 09:06 AM

    PostSharp Technologies's Avatar


    We're closing the ticket for now as the bug has been internally filed as issue #15422. We will contact you as soon as the bug fix has been released.

    For more details on our support policies and prioritization of bug fixes, please visit


  2. PostSharp Technologies closed this discussion on 31 Aug, 2017 09:06 AM.

  3. PostSharp Technologies re-opened this discussion on 18 Sep, 2017 12:20 PM

  4. Support Staff 2 Posted by PostSharp Techn... on 18 Sep, 2017 12:20 PM

    PostSharp Technologies's Avatar


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

    Best regards,

  5. PostSharp Technologies closed this discussion on 18 Sep, 2017 12:21 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