NullReferenceException when logging with ApplicationInsightsBackend

Esben Bach's Avatar

Esben Bach

18 Apr, 2018 11:54 AM

I have a project that uses the ApplicationInsightsBackend to log various things.

When logging an error i get the following exception

System.NullReferenceException with message "Object reference not set to an instance of an object."
     at PostSharp.Patterns.Diagnostics.Backends.ApplicationInsights.ApplicationInsightsLogRecordBuilder.Write(UnsafeString message)
     at PostSharp.Patterns.Diagnostics.RecordBuilders.LogRecordBuilder.Complete()
     at PostSharp.Patterns.Diagnostics.LoggingTypeSource.PostSharp.Patterns.Diagnostics.Custom.ILogger.Write(LogLevel level, LogRecordKind logRecordKind, String text, Exception exception, ILoggingContext context, CallerInfo& callerInfo)
     at PostSharp.Patterns.Diagnostics.Logger.Write(LogLevel level, String text, CallerInfo& callerInfo)
     at .....snipping out my class

The method call that causes the error is
logger.Write(LogLevel.Error, "my error message");

No idea what goes wrong, but if i switch to the ConsoleLoggingBackend everything works (and no thats not an option).

Version 5.0.49 this time around

  1. 1 Posted by Esben Bach on 18 Apr, 2018 11:57 AM

    Esben Bach's Avatar

    I am also getting a nullreference exception when doing logger.WriteException(LogLevel.Error, myException, myMessage)

    System.NullReferenceException with message "Object reference not set to an instance of an object."
       at PostSharp.Patterns.Diagnostics.Backends.ApplicationInsights.ApplicationInsightsLogRecordBuilder.SetException(Exception exception)
    
  2. 2 Posted by Esben Bach on 20 Apr, 2018 08:58 AM

    Esben Bach's Avatar

    Anything?

  3. Support Staff 3 Posted by PostSharp Techn... on 20 Apr, 2018 01:43 PM

    PostSharp Technologies's Avatar

    Hello,

    this a bug of this particular backend implementation of custom messages.

    (internal issue #16019)

    Thanks for reporting it.

    Kind regards,
    Daniel

  4. 4 Posted by Esben Bach on 11 May, 2018 10:48 AM

    Esben Bach's Avatar

    Seems like its fixed in 5.0.51 - tried to test it but for somereason the PostSharp package does not have a 5.0.51 version on NuGet (everything else seems to be properly updated).

  5. 5 Posted by Esben Bach on 11 May, 2018 01:03 PM

    Esben Bach's Avatar

    And now its there, might just have been a slow nuget.org thx!

  6. Support Staff 6 Posted by PostSharp Techn... on 11 May, 2018 01:24 PM

    PostSharp Technologies's Avatar

    Hello,

    yes, package validation was quite slow. You're welcome :-)

    Best,
    Daniel

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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