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

  7. Support Staff 7 Posted by PostSharp Techn... on 28 May, 2018 02:11 PM

    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,
    PostSharp Team

  8. PostSharp Technologies closed this discussion on 28 May, 2018 02:11 PM.

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