We are experiencing a very strange situation with Razor Mediator (v 18.104.22.168) development in Tridion 2011 SP1 with Media Manager Connector on Windows 2008 R2. The first time that you open a Razor TBB in Template Builder and run it, everything executes properly and the TBB completes (or throws an error due to a bug, as the case may be). Subsequent executions with an updated content component also run fine. However, make the simplest change to the Razor Template (add a @Debug statement, even just add a single white space), save the TBB and execute it in Template Builder, and the following error is thrown:
TemplateCompileException: CS1703: An assembly with the same identity 'Tridion.ExternalContentLibrary.V1, Version=22.214.171.1248, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b' has already been imported. Try removing one of the duplicate references. Line 0 Column 0: //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.18063 // Stack Trace: at Tridion.Extensions.Mediators.Razor.Templating.Compiler.Compile(IEnumerable`1 entries, IEnumerable`1 assemblyReferences) at Tridion.Extensions.Mediators.Razor.Templating.RazorTemplateGenerator.CompileTemplates(IEnumerable`1 assemblyReferences) at Tridion.Extensions.Mediators.Razor.RazorHandler.Compile(DateTime revisionDate) at Tridion.Extensions.Mediators.Razor.RazorHandler.Compile(DateTime revisionDate) at Tridion.Extensions.Mediators.Razor.RazorHandler.GetRazorTemplate(DateTime revisionDate, String templateID) at Tridion.Extensions.Mediators.Razor.RazorHandler.CompileAndExecute(DateTime revisionDate, Engine engine, Package package) at Tridion.Extensions.Mediators.Razor.RazorMediator.Transform(Engine engine, Template template, Package package) at Tridion.ContentManager.Templating.Engine.ExecuteTemplate(Template template, Package package) at Tridion.ContentManager.Templating.Engine.InvokeTemplate(Package package, TemplateInvocation templateInvocation, Template template) at Tridion.ContentManager.Templating.Compound.CompoundTemplateMediator.Transform(Engine engine, Template templateToTransform, Package package) at Tridion.ContentManager.Templating.Engine.ExecuteTemplate(Template template, Package package) at Tridion.ContentManager.Templating.Engine.InvokeTemplate(Package package, TemplateInvocation templateInvocation, Template template) at Tridion.ContentManager.Templating.Engine.TransformItem(Template template, IdentifiableObject itemToRender) at Tridion.ContentManager.Templating.Debugging.DebuggingEngine.Run() at Tridion.ContentManager.Templating.Debugging.DebugSession.Run()
Any subsequent executions of the TBB will result in the same error, no matter what you change in the TBB. But, if you leave things alone in Template Builder for somewhere between 30-60 minutes (we don't know exactly how long), you will be able to run the TBB again. Make another change, however, and the process repeats. In fact, once it starts, it gets "worse" if you keep trying to change your TBB. After a few saves of your TBB, you start getting the same error when saving. Again, waiting 30-60 minutes seems to clear things up.
This also happens on a per user basis, even with the same TBB. I can make a change to the TBB and experience the error. I can then check in the TBB, and another developer can run it in Template Builder. If he makes a change to the TBB, then he will receive the error. We both have to wait until things clear up to execute the TBB again.
Dreamweaver templates work fine with Media Manager Connector. Razor templates would throw the usual
The type or namespace name could not be found (are you missing a using directive or an assembly reference?) errors until the assemblies are added to the Razor config in Tridion.ContentManager.config, like so:
<razor.mediator extractBinaries="true" adminUser="NT AUTHORITY\SYSTEM"> <namespaces> <add namespace="Tridion.ExternalContentLibrary" /> <add namespace="Tridion.ExternalContentLibrary.V1" /> </namespaces> <assemblies> <add assembly="D:\app\Tridion\bin\client\Tridion.ExternalContentLibrary.V1.dll" /> <add assembly="D:\app\Tridion\bin\client\Tridion.ExternalContentLibrary.dll" /> </assemblies> <imports/> <importSettings includeConfigWhereUsed="false" includeImportWhereUsed="false" replaceRelativePaths="false"/> </razor.mediator>
Once the above was added, we could use razor templates to get assets from the Tridion.ExternalContentLibrary api, albeit with the issue as described.
There isn't much out there on the Internet with people using Razor and Media Manager Connector, but I have found one blog where the two are apparently used together successfully. That post doesn't mean they weren't experiencing this issue, but no mention was made of it so I would assume things are running as expected.
Our guess is that we have a configuration issue with either Razor or Media Manager Connector, or that the current version of Razor is bugged. Anybody have this working who can help us out?