The original problem:
I need a little clarion/.NET help. I build a .NET assembly that has 4 nuget packages some years ago. Next I wrote a clarion class to wrap my .NET assembly. I recently updated the nuget packages. My .NET unit tests all pass without error. BUT, when I move the assemblies over to my Clarion app I am getting an exception thrown. My clarion class is sending TXT, and they are getting sent, the exception comes after the send.
The exception message is
Could not load file or assembly ‘Newtonsoft.Json, Version=184.108.40.206, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I have put the Newtonsoft.json.dll (version 11) in the folder where my test app runs so I am very confused why I get a version 9 exception.
probably an issue with the bindingRedirect in the app.config. Note that in this case it is a config file for the clarion EXE that calls the wrapped .NET assembly. So if your clarion program is called invoice.exe then check the bindingRedirect in invoice.exe.config
The proposed reason:
The assembly or one of it’s dependencies is expecting to find Newtonsoft.json.dll v220.127.116.11,. The bindingRedirect in the config file let’s the thing looking for the thing know that it can also try using a different version.
The application.exe.config will know contain soethign looking like this:
<dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-18.104.22.168" newVersion="22.214.171.124" /> </dependentAssembly>
the thing dependant on Newtonsoft.Json v126.96.36.199 will now know to look for any versions between
0.0.0.0-188.8.131.52 and give them a good old go!