Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tridion: Unable to load .Net dll while publishing

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.

like image 664
Sunil Nadar Avatar asked Mar 28 '12 11:03

Sunil Nadar


3 Answers

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?

like image 184
Dominic Cronin Avatar answered Nov 04 '22 23:11

Dominic Cronin


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.

like image 6
Milee Avatar answered Nov 04 '22 22:11

Milee


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.

like image 3
Arjen Stobbe Avatar answered Nov 04 '22 23:11

Arjen Stobbe