Search code examples
c#hl7-fhir

FhirSerializer to Json and XML


I had to upgrade my library to Hl7.Fhir.Serialization 3.5.0.2 but now I am getting an Newtonsoft.Json version 11 error. It looks like the Hl7.Fhir.Serialization also had to update the Newtonsoft.Json library to 12.0.0.

Any idea why I am getting this error?

obsolete

//var result = format == Format.Json 
//    ? FhirSerializer.SerializeResourceToJson(exportModel, SummaryType.False)
//    : FhirSerializer.SerializeResourceToXml(exportModel, SummaryType.False);

Changed to

var FhirJson = new FhirJsonSerializer();
var FhirXML = new FhirXmlSerializer();


            var result =
                format == Format.Json
                ? FhirJson.SerializeToString(exportModel, SummaryType.False)
                : FhirXML.SerializeToString(exportModel, SummaryType.False);

The error I am getting

Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

solution that I tried was changing the web.config file but that didnt fix it

<dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>

Solution

  • This is working now that I have updated the oldVersion="0.0.0.0-9.0.0.0" newVersion="12.0.0.0"