2

I am writing a v2 Azure Durable Function. When passing a C# object to a helper activity Function, I get a runtime error in my custom JsonConverterused in serializing the type being passed. The custom JsonConverter is in a library that must reference Newtonsoft.Json 12.x, while Microsoft.NET.Sdk.Functions is locked into 11.0.2.

jObject error CS1705: Assembly 'ContractLibrary' with identity 'ContractLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' which has a higher version than referenced assembly 'Newtonsoft.Json' with identity 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

I believe this GitHub Issue is relevant. This comment on that Issue seems to indicate that adding Newtonsoft.Json 12.x as a direct dependency of your Function project may help. This helped in another Function project, but now I have hit this wall again. Is there anything I can do to mitigate this?

Chris Gillum
  • 14,526
  • 5
  • 48
  • 61
Scotty H
  • 6,432
  • 6
  • 41
  • 94

1 Answers1

2

One thing you can try is to bypass the serialization logic used by Durable Functions and do your own serialization. For example, instead of doing this:

public static void MyFunc([ActivityTrigger] MyCustomType input)
{
    // ...
}

Try doing this:

public static void MyFunc([ActivityTrigger] JObject json)
{
    // manually convert the JObect into MyCustomType
}

Let me know if that gets you any further.

Chris Gillum
  • 14,526
  • 5
  • 48
  • 61