I am using a .Net dll Newtonsoft.Json in my C# TBB
to process components and generate Json data. I have already added this dll in GAC[Global Assembly Cache]
, and it works as well. But sometimes it doesn't work and I get the following error while publishing:
JScriptException: Expression 'RenderComponentPresentation()' had error 'Could not load file or assembly 'Newtonsoft.Json, Version=4.0.5.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.'
But when I preview the page in Tridion it works fine. To fix this issue we restart the Tridion Services
, and after restart we publish the page it woks fine. But this problem keep on reappearing again and again. Is there any way to solve this issue permanently?
Recently I could reproduce issue when I published the same page again when it was already under the process of getting published. The second publish attempt returned the above error, but the first publish attempt finished after the failure of second publish attempt and it returned Success
. Any idea why this weird behavior.
If it weren't for the fact that it works better after restarting the service, I'd have thought this was about an assembly that NewtonSoft.Json depends on. If there are any such assemblies, then they too will need to be registered in the GAC. Note that the publisher process does not necessarily have the same application folder or probing path as the Tridion kernel (which performs previews).
As Chris says, maybe this is a threading issue, but sometimes this kind of weirdness shows up under memory pressure. Can you monitor the memory use of your publisher process to see if there's a leak?
Sometimes your platform is not set properly. Check this by right-clicking the project and setting the framework to 4.0 (or whatever is compatible) to use the dll. Then, close the application and try running it again. Your platform might be set to .NET Framework 4 client Profile.
The fusion log files could provide you with more details on why it fails. Did you use this tool already?
Fuslogvw.exe (Assembly Binding Log Viewer)
Other than that I recommend getting the latest JSON.NET versions for .NET 4.0 and ensure that you deployed the right versions to all publish servers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With