Error executing template "/Designs/Swift/Grid/Page/RowTemplates/1Column.cshtml"
System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at System.Reflection.Internal.StreamMemoryBlockProvider.ReadMemoryBlockNoLock(Stream stream, Int64 start, Int32 size)
at System.Reflection.PortableExecutable.PEReader..ctor(Stream peStream, PEStreamOptions options, Int32 size)
at Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream(Stream peStream, PEStreamOptions options)
at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.SelectMetadataReference.Visit(Assembly assembly)
at RazorEngine.Compilation.ReferenceResolver.CompilerReference.DirectAssemblyReference.Visit[T](ICompilerReferenceVisitor`1 visitor)
at System.Linq.Enumerable.SelectListIterator`2.ToArray()
at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.GetMetadataReferences(IEnumerable`1 references)
at Dynamicweb.Rendering.Compatibility.RoslynCompilerServiceBase.CompileType(TypeContext context)
at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType)
at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType)
at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType)
at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String templateSource, String name, Type modelType, Object model, DynamicViewBag viewBag)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.GridRowViewModel>
@{
string sectionClass = "py-3";
string spaceBetweenRows = Model.Item.GetRawValueString("SpaceBetweenRows", "spacing");
string spaceBetweenRowsMobile = Model.Item.GetRawValueString("SpaceBetweenRowsMobile", "auto");
//Row spacing mobile auto
if (spaceBetweenRowsMobile == "auto") {
spaceBetweenRowsMobile = spaceBetweenRows;
}
//Row spacing mobile
switch (spaceBetweenRowsMobile) {
case "none": //No spacing
sectionClass = "py-0";
break;
case "spacing": //Small spacing top and bottom
sectionClass = "py-3";
break;
case "spacing-small-top": //Small spacing top
sectionClass = "pt-3";
break;
case "spacing-small-bottom": //Small spacing bottom
sectionClass = "pb-3";
break;
case "spacing-medium": //Medium spacing top and bottom
sectionClass = "py-4";
break;
case "spacing-medium-top": //Medium spacing top
sectionClass = "pt-4";
break;
case "spacing-medium-bottom": //Medium spacing bottom
sectionClass = "pb-4";
break;
case "spacing-large": //Large spacing top and bottom
sectionClass = "py-5";
break;
case "spacing-top": //Large spacing top
sectionClass = "pt-5";
break;
case "spacing-bottom": //Large spacing bottom
sectionClass = "pb-5";
break;
}
//Row spacing dekstop
switch (spaceBetweenRows) {
case "none": //No spacing
sectionClass += " py-lg-0";
break;
case "spacing": //Small spacing top and bottom
sectionClass += " py-lg-3";
break;
case "spacing-small-top": //Small spacing top
sectionClass += " pt-lg-3 pb-lg-0";
break;
case "spacing-small-bottom": //Small spacing bottom
sectionClass += " pb-lg-3 pt-lg-0";
break;
case "spacing-medium": //Medium spacing top and bottom
sectionClass += " py-lg-5";
break;
case "spacing-medium-top": //Medium spacing top
sectionClass += " pt-lg-5 pb-lg-0";
break;
case "spacing-medium-bottom": //Medium spacing bottom
sectionClass += " pb-lg-5 pt-lg-0";
break;
case "spacing-large": //Large spacing top and bottom
sectionClass += " py-lg-6";
break;
case "spacing-top": //Large spacing top
sectionClass += " pt-lg-6 pb-lg-0";
break;
case "spacing-bottom": //Large spacing bottom
sectionClass += " pb-lg-6 pt-lg-0";
break;
}
string width = Model.Item.GetRawValueString("Width");
string containerClass = "container-xl";
if (width == "stretch")
{
containerClass = "container-fluid";
}
if (width == "none")
{
containerClass = "container-fluid px-0";
}
if (width == "compressed")
{
containerClass = " container-compressed";
}
string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
string animationOnScrollCol1 = Model.Item.GetRawValueString("AnimationOnScroll", "no-animation");
animationOnScrollCol1 = animationOnScrollCol1 != "no-animation" ? "data-aos=" + "'" + animationOnScrollCol1 + "'" : "";
string hideOverflow = " overflow-hidden";
hideOverflow = animationOnScrollCol1 != "" ? hideOverflow : "";
Dynamicweb.Frontend.FileViewModel backgroundImage = Model.Item.GetFile("BackgroundImage");
string backgroundImagePath = backgroundImage?.Path ?? string.Empty;
backgroundImagePath = !string.IsNullOrEmpty(backgroundImagePath) ? $"/Admin/Public/GetImage.ashx?image={backgroundImagePath}&width=2600&format=webp&compression=75" : string.Empty;
backgroundImagePath = Dynamicweb.Core.Encoders.HtmlEncoder.UrlPathEncode(backgroundImagePath);
string backgroundRepeat = Model.Item.GetRawValueString("BackgroundImageRepeat", "no-repeat");
string backgroundImageSize = Model.Item.GetRawValueString("BackgroundImageSize", "initial");
int xPos = backgroundImage?.FocalPositionFromLeft ?? 50;
int yPos = backgroundImage?.FocalPositionFromTop ?? 50;
string cssPosition = $"{xPos}% {yPos}%";
string gradient = Model.Item.GetRawValueString("Gradient", string.Empty);
string gradientOpacity = Model.Item.GetRawValueString("GradientOpacity", "0.00");
string gradientString = "linear-gradient(" + gradient + "deg," + "rgba(var(--swift-foreground-color-rgb)," + gradientOpacity + "), rgba(var(--swift-background-color-rgb)," + gradientOpacity + "))";
string backgroundImageString = "url(" + backgroundImagePath + ")";
string backgroundImagePositionString = "background-position:" + cssPosition + ";";
string backgroundRepeatString = "background-repeat:" + backgroundRepeat + ";";
string backgroundImageSizeString = "background-size:" + backgroundImageSize + ";";
string styleString = string.Empty;
var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>();
var css = string.Empty;
var cssClasses = new List<string> { };
foreach (var itemId in decorations)
{
var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId);
item.TryGetValue("Class", out object classes);
if (classes is null)
{
continue;
}
var cssString = (string)classes;
if (cssString.StartsWith("["))
{
var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString);
cssClasses.AddRange(cssArray);
}
else
{
cssClasses.Add(cssString.Replace(",", " "));
}
}
css = string.Join(" ", cssClasses).Trim();
@* Only gradient *@
if (!string.IsNullOrEmpty(gradient) && string.IsNullOrEmpty(backgroundImagePath) && gradientOpacity != ("0.00"))
{
styleString += "style=\"background-image:" + gradientString + ";\"";
}
@* Only background image *@
else if (string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath))
{
styleString += "style=\"background-image:" + backgroundImageString + "; " + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\"";
}
@* Gradient and background image *@
else if (!string.IsNullOrEmpty(gradient) && !string.IsNullOrEmpty(backgroundImagePath))
{
styleString += "style=\"background-image:" + gradientString + "," + backgroundImageString + ";" + backgroundImagePositionString + backgroundRepeatString + backgroundImageSizeString + "\"";
}
if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(Model.Column(1).Output()))
{
<div class="@(sectionClass)@(theme) @(css) item_@Model.Item.SystemName.ToLower()" @styleString data-swift-gridrow>
<div class="@containerClass@(hideOverflow)">
<div class="grid grid-1">
<div class="g-col" data-col-size="12" @animationOnScrollCol1 style="--bs-columns:12">
@Model.Column(1).Output()
</div>
</div>
</div>
</div>
}
}