# Using Tridion2012UI Experience Manager tags with Razor templates

I'm trying to use Dominic Cronin's Tridion2012UI functions as detailed at https://github.com/TridionPractice/tridion-practice/wiki/TridionUI2012FunctionsForUseInHtmlTemplates with Razor templates.

I have the DLL compiled and in the GAC and Tridion.ContentManager.config and it's working correctly when I test with DWT templates. I've tried the following markup in Razor templates but am unable to save the template as I'm getting "[whatever you tried] does not exist in the current context" error.

@MarkComponentField("Title")

@ExperienceManagerFunctionSource.MarkComponentField("Title")


And even the full namespace

@Client.ContentManager.ExperienceManager.ExperienceManagerFunctionSource.MarkComponentField("Title")


Am I just using the incorrect syntax here?

Have you referenced the assembly (in the GAC) within your Tridion.ContentManager.config file?

For example:

<razor.mediator cacheTime="60" extractBinaries="true" adminUser="DOMAIN\AdminUser">
<namespaces>
<!-- ... -->
</namespaces>
<assemblies>
</assemblies>
<imports>
<!-- ... -->
</imports>
</razor.mediator>


If you've already included this then reference then you may want to try restarting the COM+, Tridion Publisher service, and Template Builder (if it’s open). It is always the restarting of the Publisher service that I forget!

NOTE: You can also add your namespace into the <namespaces> section (e.g. <add namespace="Client.ContentManager.ExperienceManager" />), which will prevent you having to include the @using XXX statement at the top of each template.

• Glad you managed to sort it. It's easy to lose hours to this type of issue! – Jonathan Williams Aug 28 '15 at 16:03

There are two parts to this answer.

The first was pointed out by Jonathan Williams, I was missing the assembly reference in the razor.mediator configuration

<razor.mediator cacheTime="60" extractBinaries="true" adminUser="DOMAIN\AdminUser">
<namespaces>
<!-- ... -->
</namespaces>
<assemblies>
<add assembly="Client.ContentManagement.ExperienceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9b5801bc9141826f" />
</assemblies>
<imports>
<!-- ... -->
</imports>
</razor.mediator>


The second is that the Tridion2012UIFunctionSource class has an Initialize method that you have to call after instantiating the object like so.

{
var ExperienceManager = new Client.ContentManagement.ExperienceManager.ExperienceManagerFunctionSource();
ExperienceManager.Initialize(TridionHelper.Engine, TridionHelper.Package);
}


Then you can go and call your methods like so

@ExperienceManager.MarkPage("[http://cmeurl]")