SDL Tridion Support recommended that I post this question out here (they don't seem to have any good guesses at this point). Today I went to go update a Template Building Block (TBB) that largely has gone unchanged/untouched for a couple years now and has worked without issue. Now, when trying to make a simple change to the TBB file in question, I get this error:
Unable to save item
TemplateCompileException: CS0234: The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Line 15 Column 22: namespace Tridion.Extensions.Mediators.Razor.Templating {
using System;
(80040356) Unable to save item
TemplateCompileException: CS0234: The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Line 15 Column 22: namespace Tridion.Extensions.Mediators.Razor.Templating {
using System;
TemplateCompileException: CS0234: The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Line 15 Column 22: namespace Tridion.Extensions.Mediators.Razor.Templating {
using System;
using Tridion.Extensions.Mediators.Razor.Models;
using Tridion.ContentManager.Publishing;
* using System.Web.Script.Serialization;
public class Rzr31eda8513e3e4d0ba7e7aba065d78a1eTemplate : Tridion.Extensions.Mediators.Razor.TridionRazorTemplate {
#line hidden
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 error references this specific namespace declaration:
@using System.Web.Script.Serialization
And that declaration is used in this small block of code:
@{
dynamic obj = new JavaScriptSerializer().Deserialize<object>(TridionHelper.Package.GetByName("Navigation").GetAsString());
dynamic root = obj["Root"];
}
In my search for solutions along the way, I've seen other situations require them adding this to their Tridion.ContentManager.config or their web.config file this line in the config:
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
The curious thing is that this line isn't in our .config file AND that the config file has also not been touched in a very long time, either. SOMETHING has changed along the way and nobody on my team has a clue what would have changed and why. We're unsure if our Windows Server group has patched the servers in a way that changed something with .NET or if some patch we've been provided by SDL has changed Razor Mediator or some other change that affects namespaces.
Why would I be getting this error message (about Script not being in the System.Web namespace) and what do I do to resolve this? Do we have to modify the Tridion.ContentManager.config file or some other configuration in order for the Extensions namespace to be recognized?
Thank you in advance for any assistance or knowledge you're able to share!