6

I am finding it hard to identify an error that occurs when executing Razor template building blocks. The error message is as follows:

Engine: Error in Engine.Transform
'string' does not contain a definition for 'Title'
   at CallSite.Target(Closure , CallSite , Object )
   at Tridion.Extensions.Mediators.Razor
                     .Templating.Rzr9efd1fb529654b78b3f9321ba71e33b4Template.Execute()
   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)

This occurs at render time and not when the handler first executes a compile on saving the TBB. We've looked at the templating code, and have not been able to find an example of dereferencing a Title property on anything that looks like a string. This suggests that the issue is with a dynamically typed variable.

So far I have attempted to identify the problematic code by selective deleting/commenting and by using @Debug() statements, all without success. Any suggestions for alternative debugging strategies would be welcome. Has anyone else experienced something similar?

1
  • Can you add the Templating code that you are trying to use please? Have you got other Razor templating code working ok (i.e. is it definitely installed properly)? Commented Sep 24, 2013 at 16:55

2 Answers 2

4

It turns out that we were using

@Package.Page.Title

when what was needed was just

@Page.Title

To be honest, I was rather surprised to find that @Package.Page would yield a string, but that's what the problem was.

3

What type of field are you accessing? If the field type is not a Component Link/Keyword Field then the mediator won't return a dynamic item with a Title property.

From what it looks like you are accessing a single line text field and returning a string.

Check the schema to see what field type you are accessing and that should give you a bit more information.

1
  • Well that's the trouble. I don't know which piece of code is breaking it, but it's a good insight. Thanks. Commented Sep 25, 2013 at 5:33

Your Answer

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

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