When using external dlls within our Tridion templates, the
preview or publish of these templates will throw an error stating the external class
cannot be found.
A good solution for this issue is to merge (using the tool
ilmerge) the external dll with the new assembly. This approach does not require signing assemblies or registering
assemblies in the Global Assembly Cache. As a result, we minimise the maintenance needed
on every Content Manager server.
Find here a sample command for the post-build event I wrote for the TBB generation:
ilmerge.exe /out:<resultDLL> <externalDLL> <myNewlyCompiledDLL>
"%TRIDION_HOME%bin\client\TcmUploadAssembly.exe"/verbose/uploadpdb:true
/targeturl:<CMShostname> /folder:<tcmURI> <resultDLL>
If like the solution, you just need to download and install ilmerge. Please check this link if you get an error regarding unresolved assembly reference not allowed. It worked for me :)