Postsharp with log4net backend is throwing exception when logging

wwu's Avatar

wwu

27 Aug, 2018 08:16 AM

Our soft is using Postsharp Diagnostics Log attribute with Log4Net backend for logging.
The GlobalAspect.cs is nothing special as follows.

[assembly:
    Log(
        AttributeTargetTypeAttributes = MulticastAttributes.Public,
        AttributeTargetMemberAttributes = MulticastAttributes.Public,
        AttributePriority = 1)]
[assembly: Log(AttributeExclude = true, AttributeTargetMembers = "regex:^get_|set_", AttributePriority = 2)]

It has been working well for a long time but suddenly the following error began to show up in the log.
Could you give me some hints as how to resolve this kind of problems?
Thanks in advance.

System.InvalidOperationException: Cannot pop the AsyncLocal context {SyncMethodLoggingContext Description="MessagesHandlerExtension.OnMessage({Common.MessagesHandler}, {Processing}, "[{0}]", [ "[BUDGET],[INPUT],[E2100],[FY16.MAY]" ])", IsDisposed=False, ThreadContext.Id=4} because it is not equal to the current context {SyncMethodLoggingContext Description="Server.SctMgrDataOperator..ctor({Server.ServerInfo}, {Server.Session}, {Common.MgrStruct})", IsDisposed=False, ThreadContext.Id=8}.
at PostSharp.Patterns.Diagnostics.Contexts.LocalLoggingContextImpl.Impl.PopContext(LocalContextKind kind, LocalLoggingContextCookie& cookie)
at PostSharp.Patterns.Diagnostics.Contexts.LocalLoggingContextCookie.Restore()
at PostSharp.Patterns.Diagnostics.Contexts.SyncLoggingContext.Dispose(Boolean disposing)
at Common.MessagesHandlerExtension.OnMessage(MessagesHandler handler, MessageStatus status, String msg, String[] args)
at Server.Logic.CurrTrans.<>c__DisplayClass2_0.b__0(MgrScope scope)
at System.Threading.Tasks.Parallel.<>c__DisplayClass42_0`2.b__1()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass176_0.b__0(Object )

  1. 1 Posted by wwu on 27 Aug, 2018 08:46 AM

    wwu's Avatar

    Sorry. Forgot to provide the Postsharp version.
    It is 5.0.43.0

  2. Support Staff 2 Posted by PostSharp Techn... on 28 Aug, 2018 09:25 AM

    PostSharp Technologies's Avatar

    Hello,

    The reported issue looks similar to a known bug #15901 that has been fixed in PostSharp version 5.0.48. Please update your PostSharp NuGet packages to the latest build of 5.0 or 6.0 version and let us know whether this helped to resolve the issue.

    -alex

  3. 3 Posted by wwu on 29 Aug, 2018 08:45 AM

    wwu's Avatar

    Thanks for your swift response. I'll try to upgrade the packages and see if it helps to resolve the issue.

  4. 4 Posted by wwu on 04 Sep, 2018 12:27 AM

    wwu's Avatar

    Sorry for the late response. We have confirmed that the issue has been resolved by upgrading Postsharp NuGet packages. Thank you for your kind support.

  5. Support Staff 5 Posted by PostSharp Techn... on 04 Sep, 2018 06:59 AM

    PostSharp Technologies's Avatar

    Hello,

    We are going to close this request as we believe it was solved. Please feel free to reopen the discussion if you need more help.

    Best regards,
    Daniel

  6. PostSharp Technologies closed this discussion on 04 Sep, 2018 06:59 AM.

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

Keyboard shortcuts

Generic

? 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