Search code examples
c#nservicebus

NServiceBus.Logging failing with $ character


I am trying to implement logging feature in NServiceBus with .Net Framework 4.6.1 with C#. The library for NServiceBus is NServiceBus.Core.

I am getting compilation error as "Unexpected character $"

log.Info($"Handling: OrderPlaced for Order Id: {message.OrderId}");

Need to read the message.OrderId properly.

Any help would be greatly appreciated.


Solution

  • Is it the only place where string interpolation does not work in your project? Does this code compile?

    var str = $"{1}";
    

    If not, you should check your language level in project settings:

    1

    It should be set to C# 6.0 or higher.