Could not load file or assembly Newtonsoft.json or one of its dependencies in batch mode
One issue I have encountered when developing C# code to be called in D365 has been the above error message when running in batch mode. In this case the Newtonsoft.json is a package that I would have downloaded from nugget (it could refer to any package you download from nuget or another external dll source).
After some analysis, I have found the cause.
The batch job runs as a windows service and if you check the details you'll see it runs similar to:
"K:\AosService\WebRoot\bin\Batch.exe -service "K:\AosService\WebRoot\web.config"
However, it could be the case that the batch service is not actually using web.config for its assembly binding.
In this case, I would suggest to update the config for the batch service at:
K:\AosService\WebRoot\bin\Batch.exe.Config to make it match the one of your web.config
*This post is locked for comments