1

I have a custom class written "GetTcmUriFromWebDav" which inherits TBBFrameworkBuildingBlock. When trying to use this class in a component, it throws an error and it fails to initialize assembly and searches for some reference. The Same works in Tridion 2011 but fails in Web 8.5

public class GetTcmUriFromWebDav : TBBFrameworkBuildingBlock
    {
        public override void ExecuteTransform(ITBBFrameworkContext tbbContext)
        {
           // tbbContext.LogDebug("Testing ITG-Getting into GetTcmUriFromWebDav ");
            tbbContext.LogDebug("Processing [{0}] parameters to retrieve TcmUri values for:", tbbContext.QueryString.Count);
            foreach (String variableKey in tbbContext.QueryString.AllKeys)
            {
                Stopwatch timer = new Stopwatch();

                if (!variableKey.IsNullOrEmpty())
                {
                    //Retrieve the Value for the current Key
                    String itemWebDavOrTcmUri = tbbContext[variableKey];

                    if (!itemWebDavOrTcmUri.IsNullOrEmpty())
                    {
                        //Output detailed information that is being processed if Enhanced Debug output is enabled.
                        tbbContext.LogDebug(" - Package Variable Name: {0}", variableKey);
                        tbbContext.LogDebug(" - WebDav Url: {0}", itemWebDavOrTcmUri);

                        //Ensure the benchmark timer is running and reset for the current retrieval.
                        timer.Restart();

                        string pubwedav = tbbContext.GetContextPublication().WebDavUrl.ToString();
                        itemWebDavOrTcmUri = pubwedav + itemWebDavOrTcmUri;
                        //Retrieve the TcmUri of the Tridion Item
                        var tridionItem = tbbContext.RetrieveItemAsObject(itemWebDavOrTcmUri);
                        TcmUri tcmUri = tridionItem != null ? tridionItem.Id : null;

                        //Output detailed benchmarch retrival time for performance testing
                        tbbContext.LogDebug(" - Tridion Retrival Time: [{0}] seconds", timer.Elapsed.TotalSeconds);

                        //Now push the Final value into the Package
                        String strTcmUri = tcmUri.ToString();
                        tbbContext.PushTextDataIntoPackage(variableKey, strTcmUri);
                        tbbContext.LogDebug(" - Added variable to Package:  {0} == {1}", variableKey, strTcmUri);
                    }
                    else
                    {
                        tbbContext.LogDebug(" - Unable to add variable to Package; Zero length WebDav parameters are not allowed:  {0}", tbbContext.GetQueryStringFullString());
                    }
                }
                else
                {
                    tbbContext.LogDebug(" - Unable to add variable to Package; Zero length variable names are not allowed:  {0}", tbbContext.GetQueryStringFullString());
                }
            }

        }

##error##
Debugging was started in process 'TcmTemplateDebugHost' with id 7552
Could not compile template.
   at Tridion.ContentManager.Templating.Assembly.CSharpSourceCodeMediator.CompileAssembly(String templateCode)
   at Tridion.ContentManager.Templating.Assembly.CSharpSourceCodeMediator.<>c__DisplayClass14_0.<Transform>b__0()
   at Tridion.ContentManager.AssemblyCache.AssemblyCache.<>c__DisplayClass12_0.<GetOrAddAssemblyCacheInfo>b__0(String _)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Tridion.ContentManager.AssemblyCache.AssemblyCache.GetOrAddAssemblyCacheInfo(String script, Func`1 getAssembly, String keyAddition)
   at Tridion.ContentManager.AssemblyCache.AssemblyCache.GetInstanceOfType[T](String script, Func`1 generateAssembly, String typeName, Func`2 getType, String keyAddition)
   at Tridion.ContentManager.Templating.Assembly.CSharpSourceCodeMediator.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.TransformPackage(Template template, Package package)
   at Tridion.ContentManager.Templating.Engine.TransformItem(Template template, IdentifiableObject itemToRender)
   at Tridion.ContentManager.Templating.Debugging.DebuggingEngine.Run()
   at Tridion.ContentManager.Templating.Debugging.DebugSession.Run()
---Caused by:
Could not compile C# source code, because of: Could not load file or assembly 'HP.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f9dca51171614d83' or one of its dependencies. The system cannot find the file specified..
   at Tridion.ContentManager.CSharpCodeCompiler.LoadAssemblies(IEnumerable`1 assemblies)
   at Tridion.ContentManager.CSharpCodeCompiler.CompileAssembly(String code, String namespaceName, String classDeclaration, String methodName, CompilationPurpose compilationPurpose, Type methodType, String usingDeclarations, IDictionary`2 properties, IEnumerable`1 additionalReferencedAssemblies, String customDeclarations, String outputAssemblyPath)
   at Tridion.ContentManager.Templating.Assembly.CSharpSourceCodeMediator.CompileAssembly(String templateCode)
---Caused by:
Could not load file or assembly 'HP.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f9dca51171614d83' or one of its dependencies. The system cannot find the file specified.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at Tridion.ContentManager.CSharpCodeCompiler.<>c.<LoadAssemblies>b__8_0(String assembly)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Tridion.ContentManager.CSharpCodeCompiler.LoadAssemblies(IEnumerable`1 assemblies)
1
  • TBBFrameworkBuildingBlock seems to be some custom developed class, which you are inheriting from. There's not much we can do to help you here. It might be useful to clearly specify which error you get, instead of mentioning there is "some" error. Can you put the full error message/stack trace you see when the problem occurs? Mar 17, 2020 at 10:16

2 Answers 2

4

You are doing an upgrade from 2013 to 8.5 so that means that all your custom assemblies must also be upgraded. What it means is that they (in their implementation reference 2013 dlls.) So you need to update each of those to use 8.5 dlls, and reupload them in Tridion.TBBFrameworkBuildingBlock is an example of custom assembly your team created. :D

1

From the error message/stack trace you posted, it looks like this assembly is missing

Could not load file or assembly 'HP.Common,...

This means that a dll HP.Common can not be found on the CM server where you are trying to run the TBB code.

Most likely, this dll should be added to the GAC. Can you check if you can locate this dll in the 2013 environment you are upgrading from?

2
  • Thank you for the suggestion. I tried adding the dll in GAC, it gives the below error " Failure adding assembly to the cache: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. " Mar 17, 2020 at 14:11
  • see if this helps stackoverflow.com/questions/57189959/…. Note : are you using gacutil (a visual studio tool) to add this to the GAC? This is ok for dev purposes, but doesn't work well on a production environment. Try doing this via powershell (see andrewcbancroft.com/2015/12/16/…) instead Mar 18, 2020 at 9:08

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.