2

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.LoadExtensions()
Tridion.ContentManager.Extensibility.TcmExtension.LoadExtensions()
Tridion.ContentManager.Extensibility.TcmExtension.InitializeExtensions()
Tridion.ContentManager.Session.InitializeSession()
Tridion.ContentManager.Session..ctor(String,String,UserContext)
Tridion.ContentManager.BLFacade.SystemFacade.InitializeUserContext(UserContext,String,String)
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?

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

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.

  1. Download ILMerge from http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx
  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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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