So, we have two different TBBs and want to reuse shared code in some common library. Queston is: how to reference to some external assembly in project which are using for TBB. Because now I can upload only source dll into Tridion and it doesn't have an idea where look up an external dll.

Thanks in advance.

P.S. Please don't suggest ILMerge.

  • Any reason not to use ILMerge? I thought at first this was complicated, but actually got it working pretty quickly. We use this to share common projects (TOM.NET helper functions which are shared between TBBs and Event sys for example). I would put 3rd party dlls in the GAC however
    – Will Price
    Dec 19, 2013 at 15:29
  • The problem is that ILMerge doesn't work correctly in my case. It's just freezing without any response. Unfortunately we don't have direct access to Tridion Prod server and we want to avoid requesting deployment to put external dll into GAC every time. Anyway, thank you for your opinion.
    – Vitaliy
    Dec 19, 2013 at 16:35

2 Answers 2


If you don't want to merge your external dll, i think your next best option is to put that external assembly in the GAC of your CMS server that's used to publish content.

It might also work if you put the DLL in your tridion bin folder.

  • Unfortunately we don't have access to tridion server, but thanks anyway.
    – Vitaliy
    Dec 19, 2013 at 16:39
  • 3
    @Vitaliy You should probably stipulate these constraints in your question.
    – Ant P
    Dec 19, 2013 at 16:41

A third option (after considering the previous answers where they suggested ILMerge and the GAC) would be to use your own mechanism to load the DLL dynamically.

This is by far the hackiest, but if you're looking at options, this could be a solution for your problem. However, I would really suggest you use ILMerge (my favorite) or GAC.

The idea is to use the C# reflection API to load the DLL:

Assembly myDLL = Assembly.LoadFile("C:\\mydlls\\mytest.dll");

Then you can use either Assembly.GetTypes() to enumerate the collection of classes inside the assembly, or get one by name using Assembly.GetType(name).

Further, you would create an object of that class by calling an activator on it Activator.CreateInstance(type) for a parameterless constructor, or get a constructor with Type.GetConstructors() and invoke them using reflection.

To make your solution nicer -- i.e. not depend on a DLL on the file system, you could place the 'common' DLL in an Assembly TBB in Tridion, then read its bytes and create an Assembly from bytes. This is pretty much what Tridion templating engine does behind the scene. This could get complex though...

TemplateBuildingBlock tbb = session.GetObject("tcm:1-2-2048") as TemplateBuildingBlock;
byte[] byteArray = tbb.BinaryContent.GetByteArray();
Assembly myDLL = Assembly.Load(byteArray);
  • While this is indeed the third way of doing it, it gets very tricky if the 'parent' dll is also already loaded by using Assembly.LoadFile (as for instance happens for Event systems), because I think the AppDomain gets confused somehow. It also gets tricky when dlls need an app.config. Have you ever seen this working for Templating dlls?
    – Raimond
    Dec 23, 2013 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.