Error executing template "Designs/Swift/Paragraph/Swift_ProductListComponentParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.Content.PageService.GetPageOrLanguage(Int32 pageId, Int32 areaId)
   at CompiledRazorTemplates.Dynamic.RazorEngine_d2ab28e8280a4afd86f63d6d1cfe12a3.Execute() in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductListComponentParagraph.cshtml:line 11
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, 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 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.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 5 @{ 6 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 7 8 int itemSourcePageId = Convert.ToInt32(Model.Item.GetRawValueString("ComponentSource", "0")); 9 10 var pageService = new Dynamicweb.Content.PageService(); 11 itemSourcePageId = itemSourcePageId > 0 && pageService.GetPageOrLanguage(itemSourcePageId, Pageview.AreaID) != null ? pageService.GetPageOrLanguage(itemSourcePageId, Pageview.AreaID).ID : itemSourcePageId; 12 } 13 14 @if (itemSourcePageId != 0) { 15 var page = Dynamicweb.Content.Services.Pages.GetPage(itemSourcePageId); 16 17 if (page != null) { 18 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 19 string itemTheme = !string.IsNullOrWhiteSpace(pageViewModel.Item.GetRawValueString("Theme")) ? " theme " + pageViewModel.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 20 21 <div class="@itemTheme item_@Model.Item.SystemName.ToLower()"> 22 @{ @RenderGrid(itemSourcePageId) } 23 </div> 24 } else if (Pageview.IsVisualEditorMode) { 25 <div class="alert alert-dark m-0" role="alert"> 26 <span>@Translate("The selected component does not exist anymore")</span> 27 </div> 28 } 29 } else if (Pageview.IsVisualEditorMode) { 30 <div class="alert alert-dark m-0" role="alert"> 31 <span>@Translate("Product component: The component will be shown here, if any")</span> 32 </div> 33 } 34
Error executing template "Designs/Swift/Paragraph/Swift_ProductListComponentParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.Content.PageService.GetPageOrLanguage(Int32 pageId, Int32 areaId)
   at CompiledRazorTemplates.Dynamic.RazorEngine_d2ab28e8280a4afd86f63d6d1cfe12a3.Execute() in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductListComponentParagraph.cshtml:line 11
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, 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 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.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 5 @{ 6 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 7 8 int itemSourcePageId = Convert.ToInt32(Model.Item.GetRawValueString("ComponentSource", "0")); 9 10 var pageService = new Dynamicweb.Content.PageService(); 11 itemSourcePageId = itemSourcePageId > 0 && pageService.GetPageOrLanguage(itemSourcePageId, Pageview.AreaID) != null ? pageService.GetPageOrLanguage(itemSourcePageId, Pageview.AreaID).ID : itemSourcePageId; 12 } 13 14 @if (itemSourcePageId != 0) { 15 var page = Dynamicweb.Content.Services.Pages.GetPage(itemSourcePageId); 16 17 if (page != null) { 18 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(page); 19 string itemTheme = !string.IsNullOrWhiteSpace(pageViewModel.Item.GetRawValueString("Theme")) ? " theme " + pageViewModel.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 20 21 <div class="@itemTheme item_@Model.Item.SystemName.ToLower()"> 22 @{ @RenderGrid(itemSourcePageId) } 23 </div> 24 } else if (Pageview.IsVisualEditorMode) { 25 <div class="alert alert-dark m-0" role="alert"> 26 <span>@Translate("The selected component does not exist anymore")</span> 27 </div> 28 } 29 } else if (Pageview.IsVisualEditorMode) { 30 <div class="alert alert-dark m-0" role="alert"> 31 <span>@Translate("Product component: The component will be shown here, if any")</span> 32 </div> 33 } 34