Error executing template "Designs/v2/_parsed/page.parsed.cshtml"
System.ArgumentException: Object type cannot be converted to target type.
   at RazorEngine.Compilation.CrossAppDomainCleanUp.CleanupHelper.Init(AppDomain domain, IPrinter printer)
   at RazorEngine.Compilation.CrossAppDomainCleanUp.InitHelper.CreateHelper()
   at RazorEngine.Compilation.ExecutionContextLessThread.CallHelperSafeHelper`2.AsAction()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at RazorEngine.Compilation.ExecutionContextLessThread.DefaultCallFunc[O](Func`1 f)
   at RazorEngine.Compilation.CrossAppDomainCleanUp..ctor(AppDomain toWatch, IPrinter printer)
   at RazorEngine.Compilation.CrossAppDomainCleanUp.CreateInitial()
   at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Lazy`1.get_Value()
   at RazorEngine.Compilation.CrossAppDomainCleanUp.RegisterCleanup(String item, Boolean throwOnDefault)
   at RazorEngine.Templating.InvalidatingCachingProvider.CacheTemplate(ICompiledTemplate template, ITemplateKey templateKey)
   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.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 <!DOCTYPE HTML> 2 <!-- 3 Based on Industrious by TEMPLATED 4 templated.co (at)templatedco 5 Released for free under the Creative Commons Attribution 3.0 license (templated.co/license) 6 ** THE ORIGINAL WORK HAS BEEN MODIFIED ** 7 --> 8 9 @using System; 10 @using System.Text; 11 @using System.Data; 12 @using Dynamicweb.Data; 13 @using System.Web; 14 15 @functions{ 16 17 int MemberCount(string area) 18 { 19 int count = 0; 20 21 using(var connection = Database.CreateConnection()){ 22 23 using (var command = connection.CreateCommand()) 24 { 25 string sql = "SELECT count(*) as cnt FROM page WHERE pageitemtype = 'member' AND pageareaid = " + @area + " AND pageactive = 'true'"; 26 27 command.CommandText = sql; 28 29 using (var reader = command.ExecuteReader()) 30 { 31 while (reader.Read()) 32 { 33 34 count = int.Parse(reader[0].ToString()); 35 } 36 37 } 38 } 39 } 40 return count; 41 } 42 43 } 44 45 @{ 46 var lang = GetGlobalValue("Global:Area.LongLang"); 47 var area = GetGlobalValue("Global:Area.ID"); 48 var Areaname = GetGlobalValue("Global:Area.Name").Replace("ø", "oe").ToLower(); 49 50 var title = GetString("Title"); 51 var pageurl = GetGlobalValue("Global:Request.Scheme") + "://" + GetGlobalValue("Global:Request.Host") + GetGlobalValue("Global:Pageview.Url"); 52 var pagedescription = GetString("Meta.Description"); 53 var defaultshareimg = GetString("Item.Area.ShareImage"); 54 55 var navigationtag = GetGlobalValue("Global:Page.NavigationTag"); 56 var sitelogo = GetString("Item.Area.Logo"); 57 var sitelink = "/" + Areaname; 58 var sitename = GetString("Item.Area.Name"); 59 var payoff = GetString("Item.Area.Payoff"); 60 var link = GetString("Item.Area.PayoffLink"); 61 var linktxt = GetString("Item.Area.LinkText"); 62 var symbol_w = GetString("Item.Area.AltSymbol"); 63 var symbol = GetString("Item.Area.Symbol"); 64 var vat = GetString("Item.Area.VAT"); 65 var about = GetString("Item.Area.About"); 66 var address = GetString("Item.Area.Address"); 67 var address2 = GetString("Item.Area.Address2"); 68 var phone = GetString("Item.Area.Phone"); 69 var email = GetString("Item.Area.Email"); 70 var skype = GetString("Item.Area.Skype"); 71 var hours = GetString("Item.Area.Hours"); 72 73 bool newsletter = GetBoolean("Item.Area.Newsletter"); 74 75 var fblink = GetString("Item.Area.FbLink"); 76 var instalink = GetString("Item.Area.InstaLink"); 77 var inlink = GetString("Item.Area.InLink"); 78 var ytlink = GetString("Item.Area.YtLink"); 79 var twlink = GetString("Item.Area.TwLink"); 80 var fbpixel = GetString("Item.Area.FbPixel"); 81 } 82 83 <html lang='@lang'> 84 <head> 85 <!-- Global site tag (gtag.js) - Google Analytics --> 86 <script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-156843986-1"></script> 87 <script> 88 window.dataLayer = window.dataLayer || []; 89 function gtag(){dataLayer.push(arguments);} 90 gtag('js', new Date()); 91 92 gtag('config', 'UA-156843986-1', { 'anonymize_ip': true }); 93 </script> 94 95 <title>@GetValue("Title")</title> 96 @GetValue("MetaTags") 97 @GetValue("CopyRightNotice") 98 99 <meta charset="utf-8"> 100 <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> 101 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 102 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 103 104 <meta property="og:url" content="@pageurl"> 105 <meta property="og:title" content="@title"> 106 <meta property="og:description" content="@pagedescription"> 107 <meta property="og:type" content='website'> 108 @RenderSnippet("FbMetaImg") 109 <meta property="og:image:width" content="1200px"> 110 <meta property="og:image:height" content="510px"> 111 112 <link rel="shortcut icon" href="/Files/Templates/Designs/v2/assets/gfx/favicon.ico" type="image/x-icon"> 113 <link rel="icon" href="/Files/Templates/Designs/v2/assets/gfx/favicon.ico" type="image/x-icon"> 114 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700" type="text/css"> 115 <script src="https://kit.fontawesome.com/2b4a6fd4ef.js"></script> 116 117 <link rel="stylesheet" href="/Files/Templates/Designs/v2/assets/css/unslider.css"> 118 <link rel="stylesheet" href="/Files/Templates/Designs/v2/assets/css/main.css"> 119 120 @if(!String.IsNullOrEmpty(@fbpixel)) { 121 @fbpixel 122 } 123 124 @GetValue("Stylesheets") 125 @GetValue("Javascripts") 126 </head> 127 128 <body class="is-preload @navigationtag"> 129 130 <!-- Header --> 131 <div id="header"> 132 <div class="inner"> 133 <div> 134 <h1><a class="logo" href="@sitelink" style="background-image:url('@sitelogo')">@sitename</a></h1> 135 <div class="members @Areaname"><a href="@sitelink/medlemmer"><span id="membercount"><span id="membercount">@MemberCount(@area)</span></span> Medlemmer</a></div> 136 <div class="signup"><a class="button primary special" href="@sitelink/bli-medlem">Bli medlem</a></div> 137 </div> 138 </div> 139 <div class="menubar"> 140 <div class="inner"> 141 <h1><a class="symbol" href="@sitelink" style="background-image:url('@symbol_w')">@sitename</a></h1> 142 <div class="menu"> 143 @GetValue("DwNavigation(nav)") 144 <a href="#menu" id="navtoggle" title="Meny"><span>Meny</span></a> 145 <!--a href="/kontakt" id="contact" title="Kontakt oss">Kontakt</a--> 146 <div class="social"> 147 @if(!String.IsNullOrEmpty(@fblink)) { 148 <a href="@fblink" title="Facebook" target="_blank"><i class="fab fa-facebook-f"></i></a> 149 } 150 @if(!String.IsNullOrEmpty(@instalink)) { 151 <a href="@instalink" title="Instagram" target="_blank"><i class="fab fa-instagram"></i></a> 152 } 153 @if(!String.IsNullOrEmpty(@inlink)) { 154 <a href="@inlink" title="LinkedIn" target="_blank"><i class="fab fa-linkedin-in"></i></a> 155 } 156 @if(!String.IsNullOrEmpty(@ytlink)) { 157 <a href="@ytlink" title="Youtube" target="_blank"><i class="fab fa-youtube"></i></a> 158 } 159 @if(!String.IsNullOrEmpty(@twlink)) { 160 <a href="@twlink" title="Twitter" target="_blank"><i class="fab fa-twitter"></i></a> 161 } 162 </div> 163 </div> 164 </div> 165 </div> 166 </div> 167 168 <nav id="path"> 169 <div class="inner"> 170 @GetValue("DwNavigation(navpath)") 171 </div> 172 </nav> 173 174 <!-- Content --> 175 176 177 178 179 180 @SnippetStart("FbMetaImg") 181 <meta property="og:image" content='@GetGlobalValue("Global:Request.Scheme")://@GetGlobalValue("Global:Request.Host")@defaultshareimg'> 182 @SnippetEnd("FbMetaImg") 183 184 <section id="content">@GetValue("DwContent(content)")</section> 185 186 187 <!-- Footer --> 188 <footer id="footer"> 189 <div class="inner"> 190 <div class="content"> 191 <section class="about"> 192 <h3 class="logo"> 193 <a href="@sitelink" style="background-image:url('@symbol')">@sitename</a> 194 </h3> 195 @if(!String.IsNullOrEmpty(@vat)) { 196 <p><small>Org.nr @vat</small></p> 197 } 198 <p>@payoff</p> 199 @about 200 @GetValue("DwNavigation(about)") 201 </section> 202 @if(newsletter) { 203 <section class="contact"> 204 <h4 class="upper">Nyhetsbrev</h4> 205 <div class="signup"> 206 <span>Ønsker du at vi holder deg oppdatert?</span> 207 <a href="@sitelink/om-oss/nyhetsbrev" class="button primary">Meld deg på vårt nyhetsbrev</a> 208 </div> 209 </section> 210 } 211 <section id="social"> 212 <div class="social"> 213 @if(!String.IsNullOrEmpty(@fblink)) { 214 <a href="@fblink" title="Facebook" target="_blank"><i class="fab fa-facebook-f"></i></a> 215 } 216 @if(!String.IsNullOrEmpty(@instalink)) { 217 <a href="@instalink" title="Instagram" target="_blank"><i class="fab fa-instagram"></i></a> 218 } 219 @if(!String.IsNullOrEmpty(@inlink)) { 220 <a href="@inlink" title="LinkedIn" target="_blank"><i class="fab fa-linkedin-in"></i></a> 221 } 222 @if(!String.IsNullOrEmpty(@ytlink)) { 223 <a href="@ytlink" title="Youtube" target="_blank"><i class="fab fa-youtube"></i></a> 224 } 225 @if(!String.IsNullOrEmpty(@twlink)) { 226 <a href="@twlink" title="Twitter" target="_blank"><i class="fab fa-twitter"></i></a> 227 } 228 </div> 229 </section> 230 </div> 231 <div class="copyright"> 232 &copy;@GetGlobalValue("Global:Server.Date.Year") <a href="@sitelink">@sitename</a> • Design og utvikling: <a class="devby" href="https://koment.no" target="_blank">KOMENT</a> 233 </div> 234 </div> 235 </footer> 236 237 <!-- Scripts --> 238 <script src="/Files/Templates/Designs/v2/assets/js/jquery.min.js"></script> 239 <script src="/Files/Templates/Designs/v2/assets/js/browser.min.js"></script> 240 <script src="/Files/Templates/Designs/v2/assets/js/breakpoints.min.js"></script> 241 <script src="/Files/Templates/Designs/v2/assets/js/jquery.scrolly.min.js"></script> 242 <script src="/Files/Templates/Designs/v2/assets/js/jquery.event.move.js"></script> 243 <script src="/Files/Templates/Designs/v2/assets/js/jquery.event.swipe.js"></script> 244 <script src="/Files/Templates/Designs/v2/assets/js/unslider-min.js"></script> 245 <script src="/Files/Templates/Designs/v2/assets/js/countUp.js" type="module"></script> 246 <script src="https://player.vimeo.com/api/player.js"></script> 247 <script src="/Files/Templates/Designs/v2/assets/js/util.js"></script> 248 <script src="/Files/Templates/Designs/v2/assets/js/main.js" type="module"></script> 249 250 </body> 251 </html>