# Could not load file or assembly '...' or one of its dependencies

I have an assembly MyEventAssembly.dll that subscribes to various events in the tridion event system. It references another assembly MySharedAssembly.dll. MySharedAssembly.dll references Tridion.Common.dll, Tridion.ContentManager.dll, Tridion.ContentManager.Common.dll, Tridion.ContenetManage.Publisher.dll and Tridion.Logging.dll.

I stop IIS, stop all Tridion services and end the dllhst3g.exe. I copy MyEventAssembly.dll, MySharedAssembly.dll into C:\Program Files (x86)\Tridion\bin. I then start IIS and the Tridion Content Manager Service Host service. I then access the content manager through my web browser where I am presented with the following message

Could not load file or assembly 'MySharedAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Unable to Initialize TDSE object. Initialization of the extension 'C:\Program Files (x86)\Tridion\bin\MyEventAssembly.dll' failed.

System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly,ObjectHandleOnStack)
System.Reflection.RuntimeAssembly.GetExportedTypes()
Tridion.ContentManager.Extensibility.TcmExtension.InitializeExtensions()
Tridion.ContentManager.Session.InitializeSession()
Tridion.ContentManager.Session..ctor(String,String,UserContext)
UtilitiesTDS.GetUserContext
TDSE.Initialize


I also get the same error in the windows event log on the content manager server.

If I access the content manager a second time through the web browser I receive no error message and the UI loads as expected.

I have tried putting the dependent assemblies (MySharedAssembly.dll, Tridion.Common.dll, Tridion.ContentManager.dll, Tridion.ContentManager.Common.dll, Tridion.ContenetManage.Publisher.dll and Tridion.Logging.dll) into various bin directories in the Tridion folder such as C:\Program Files (x86)\Tridion\bin and C:\Program Files (x86)\Tridion\webservices\bin but with no success.

Where should I put the referenced assemblies? Is there any way I can solve it without registering the assemblies in the GAC?

• Put your shared assembly in GAC Mar 26 '15 at 13:45
• @user978511 Is there a solution that doesn't involve putting the assemblies in the GAC? Mar 26 '15 at 13:50
• AFAIK there's no other solution Mar 26 '15 at 14:11
• You could use a tool like ILMerge to create a single assembly. Then you can reference that in Tridion.ContentManager.config. Mar 26 '15 at 14:12
• I see two Answers in the form of Comments... Mar 27 '15 at 8:27

After reading the following blog post

http://www.curlette.com/?p=1403

It appears that Tridion likes to have a single dll. I've now given up with the idea that I can make my proposed solution work. Instead I've used ILMerge as suggested by Peter Kjaer to combine all my assemblies into one.

2. Create a new console project and add ILMerge.exe as a reference.
3. Add the following code to the console project and run it to create the merged assembly

static void Main(string[] args)
{
var ilmerge = new ILMerging.ILMerge();
ilmerge.SetInputAssemblies(new string[] {
@"C:\path\to\MyEventAssembly.dll",
@"C:\path\to\MySharedAssembly.dll"
});
// if you get any errors when merging you might have to uncomment this
//ilmerge.SetTargetPlatform("v4", @"C:\Windows\Microsoft.NET\Framework\v4.0.30319");
ilmerge.OutputFile = @"C:\dev\MyEventAssembly.ILMerged.dll";
ilmerge.Merge();
}


Using the MyEventAssembly.ILMerged.dll from the event system now works as expected with no errors.

I'll update this with the equivalent post-build script once I've written it.