4

I'm getting the following error when publishing a DCP using a Razor TBB that has references to the KeywordModel class.

TemplateCompileException: CS0246: The type or namespace name 'KeywordModel' could not be found (are you missing a using directive or an assembly reference?) 

[[ code removed]]

CS0246: The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?) 

[[ code removed]]

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)

The DCPs preview in the CM fine and publish without problems in a different dev environment.

Any ideas?

2

One quick solution (although not the ideal one) you can try by placing following lines in the top of your Razor Template:

@using Tridion.Extensions.Mediators.Razor.Models;
@using System.Collections;
@using System.Collections.Generic;

and it should be working after that.

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.