Antaris/RazorEngine

Published web-application can't compile razor template

Opened this issue · 0 comments

I created an application where I can write templates and those are compiled at runtime. When using the application on localhost with debug-config everything works. After I published on my server the compilation takes a few minutes and then I get following exception:

RazorEngine.Templating.TemplateCompilationException: Errors while compiling a Template. Please try the following to solve the situation: * If the problem is about missing/invalid references or multiple defines either try to load the missing references manually (in the compiling appdomain!) or Specify your references manually by providing your own IReferenceResolver implementation. See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details. Currently all references have to be available as files! * If you get 'class' does not contain a definition for 'member': try another modelType (for example 'null' to make the model dynamic). NOTE: You CANNOT use typeof(dynamic) to make the model dynamic! Or try to use static instead of anonymous/dynamic types. More details about the error: - error: (0, 0) An expression is too long or complex to compile Temporary files of the compilation can be found in (please delete the folder): C:\Windows\TEMP\RazorEngine_vzyylvvu.iqy The template we tried to compile is: ------------- START ----------- (then here my template) ------------- END ----------- The generated source code is: ------------- START ----------- //------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace CompiledRazorTemplates.Dynamic { using System; using System.Collections.Generic; using System.Linq; using dasteam.Newsletter.Data.Definitions; using dasteam.Framework.Extensions; using WWWdasteamAdmin.Models.Newsletter; public class RazorEngine_37dd561f31a846f9b0259c646d7d4b8f : RazorEngine.Templating.TemplateBase { public RazorEngine_37dd561f31a846f9b0259c646d7d4b8f() { } public override void Execute() { WriteLiteral("\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n #outlook a {\r\n padding: 0;\r\n }\r\n\r\n .ExternalC" + "lass {\r\n width: 100%;\r\n }\r\n\r\n .ExternalClass,\r\n " + " .ExternalClass p,\r\n .ExternalClass span,\r\n .Extern" + "alClass font,\r\n .ExternalClass td,\r\n .ExternalClass div {\r" + "\n line-height: 100%;\r\n }\r\n\r\n table td {\r\n " + " border-collapse: collapse;\r\n mso-line-height-rule: exactly;\r\n " + " }\r\n\r\n .editable.image {\r\n font-size: 0 !important;\r\n " + " line-height: 0 !important;\r\n }\r\n\r\n .nl2go_preheader {\r\n " + " display: none !important;\r\n mso-hide: all !important;\r\n " + " mso-line-height-rule: exactly;\r\n visibility: hidden !important" + ";\r\n line-height: 0px !important;\r\n font-size: 0px !importa" + "nt;\r\n }\r\n\r\n body {\r\n width: 100% !important;\r\n " + " -webkit-text-size-adjust: 100%;\r\n -ms-text-size-adjust: 100%;\r\n " + " margin: 0;\r\n padding: 0;\r\n }\r\n\r\n img {\r\n " + " outline: none;\r\n text-decoration: none;\r\n -ms-interp" + "olation-mode: bicubic;\r\n }\r\n\r\n a img {\r\n border: none;\r" + "\n }\r\n\r\n p {\r\n margin: 1em 0;\r\n }\r\n\r\n tabl" + "e {\r\n border-collapse: collapse;\r\n mso-table-lspace: 0pt;\r" + "\n mso-table-rspace: 0pt;\r\n }\r\n\r\n th {\r\n font" + "-weight: normal;\r\n text-align: left;\r\n }\r\n\r\n .nl2go-hid" + "e {\r\n display: none;\r\n display: none !important;\r\n " + "}\r\n \r\n \r\n "); WriteLiteral("@media (max-width: 600px) {\r\n .gmx-killpill {\r\n content" + ": \' \\03D1\';\r\n }\r\n }\r\n \r\n \r\n "); WriteLiteral("@media (max-width: 600px) {\r\n .gmx-killpill {\r\n content" + ": \' \\03D1\';\r\n }\r\n .r0-c {\r\n box-sizing: bor" + "der-box !important;\r\n text-align: center !important;\r\n " + " valign: top !important;\r\n width: 320px !important\r\n " + " }\r\n .r1-o {\r\n Margin: 0 auto 0 auto !important;\r\n " + " border-style: solid !important;\r\n width: 320px !imp" + "ortant\r\n }\r\n .r2-i {\r\n background-color: #f" + "fffff !important\r\n }\r\n .r3-c {\r\n box-sizing" + ": border-box !important;\r\n text-align: center !important;\r\n " + " valign: top !important;\r\n width: 100% !important\r\n " + " }\r\n .r4-o {\r\n Margin: 0 auto 0 auto !important;" + "\r\n border-style: solid !important;\r\n width: 100% !" + "important\r\n }\r\n .r5-i {\r\n padding-bottom: 1" + "0px !important;\r\n padding-left: 10px !important;\r\n " + " padding-right: 10px !important;\r\n padding-top: 10px !important\r\n" + " }\r\n .r6-c {\r\n box-sizing: border-box !impo" + "rtant;\r\n display: block !important;\r\n valign: top " + "!important;\r\n width: 100% !important\r\n }\r\n " + ".r7-o {\r\n border-style: solid !important;\r\n width:" + " 100% !important\r\n }\r\n .r8-i {\r\n padding-le" + "ft: 10px !important;\r\n padding-right: 10px !important\r\n " + " }\r\n .r9-c {\r\n box-sizing: border-box !important;\r\n " + " text-align: left !important;\r\n valign: top !importa" + "nt;\r\n width: 100% !important\r\n }\r\n .r10-o {" + "\r\n Margin: 0 auto 0 0 !important;\r\n border-style: " + "solid !important;\r\n width: 100% !important\r\n }\r\n " + " .r11-i {\r\n text-align: left !important\r\n }\r\n " + " .r12-i {\r\n text-align: right !important\r\n }\r\n " + " .r13-i {\r\n padding-top: 10px !important;\r\n " + " text-align: left !important\r\n }\r\n .r14-i {\r\n " + " padding-top: 15px !important;\r\n text-align: left !important" + "\r\n }\r\n .r15-i {\r\n text-align: center !impor" + "tant\r\n }\r\n .r16-r {\r\n background-color: #63" + "6363 !important;\r\n border-color: #636363 !important;\r\n " + " border-radius: 5px !important;\r\n border-width: 1px !importan" + "t;\r\n box-sizing: border-box;\r\n height: initial !im" + "portant;\r\n padding-bottom: 12px !important;\r\n padd" + "ing-left: 6px !important;\r\n padding-right: 6px !important;\r\n " + " padding-top: 12px !important;\r\n text-align: center !im" + "portant;\r\n width: 100% !important\r\n }\r\n .r1" + "7-o {\r\n Margin: 0 auto 0 0 !important;\r\n border-st" + "yle: solid !important;\r\n margin-top: 10px !important;\r\n " + " width: 100% !important\r\n }\r\n .r18-c {\r\n " + " box-sizing: border-box !important;\r\n text-align: center !impor" + "tant;\r\n width: 100% !important\r\n }\r\n .r19-i" + " {\r\n padding-bottom: 10px !important;\r\n padding-to" + "p: 10px !important\r\n }\r\n .r20-c {\r\n box-siz" + "ing: border-box !important;\r\n width: 100% !important\r\n " + " }\r\n .r21-c {\r\n display: none !important\r\n " + "}\r\n .r22-c {\r\n box-sizing: border-box !important;\r\n " + " width: 32px !important\r\n }\r\n .r23-o {\r\n " + " border-style: solid !important;\r\n margin-right: 5px !im" + "portant;\r\n width: 32px !important\r\n }\r\n .r2" + "4-c {\r\n border: none !important;\r\n box-sizing: bor" + "der-box !important;\r\n display: inline-block !important;\r\n " + " height: auto !important;\r\n text-align: right !important;\r" + "\n visibility: visible !important;\r\n width: 100% !i" + "mportant\r\n }\r\n .r25-o {\r\n Margin: 0 0 0 aut" + "o !important;\r\n border: none !important;\r\n border-" + "style: solid !important;\r\n display: inline-block !important;\r\n " + " height: auto !important;\r\n visibility: visible !impo" + "rtant;\r\n width: 100% !important\r\n }\r\n .r26-" + "i {\r\n padding-left: 95px !important;\r\n padding-rig" + "ht: 0px !important\r\n }\r\n .r27-c {\r\n border:" + " none !important;\r\n box-sizing: border-box !important;\r\n " + " display: inline-block !important;\r\n height: auto !importan" + "t;\r\n visibility: visible !important;\r\n width: 32px" + " !important\r\n }\r\n .r28-o {\r\n border: none !" + "important;\r\n border-style: solid !important;\r\n dis" + "play: inline-block !important;\r\n height: auto !important;\r\n " + " margin-right: 5px !important;\r\n visibility: visible !im" + "portant;\r\n width: 32px !important\r\n }\r\n bod" + "y {\r\n -webkit-text-size-adjust: none\r\n }\r\n " + ".nl2go-responsive-hide {\r\n display: none\r\n }\r\n " + " .nl2go-body-table {\r\n min-width: unset !important\r\n " + " }\r\n .mobshow {\r\n height: auto !important;\r\n " + " overflow: visible !important;\r\n max-height: unset !importa" + "nt;\r\n visibility: visible !important;\r\n border: no" + "ne !important\r\n }\r\n .resp-table {\r\n display" + ": inline-table !important\r\n }\r\n .magic-resp {\r\n " + " display: table-cell !important\r\n }\r\n }\r\n \r\n " + " \r\n \r\n \r\n \r\n \r\n .nl2go-default-textstyle {\r\n color: #636363;\r\n f" + "ont-family: Arial, Helvetica, sans-serif;\r\n font-size: 14px\r\n " + "}\r\n\r\n a,\r\n a:link {\r\n color: #636363;\r\n font" + "-weight: normal;\r\n text-decoration: none\r\n }\r\n\r\n .nl2go" + "_class_14_blue {\r\n color: #41B8FF;\r\n font-family: Arial, H" + "elvetica, sans-serif;\r\n font-size: 14px\r\n }\r\n\r\n .nl2go_" + "class_14_blue_b {\r\n color: #41B8FF;\r\n font-family: Arial, " + "Helvetica, sans-serif;\r\n font-size: 14px;\r\n font-weight: 7" + "00\r\n }\r\n\r\n .nl2go_class_14_grey1 {\r\n color: #636363;\r\n " + " font-family: Arial, Helvetica, sans-serif;\r\n font-size: 14" + "px\r\n }\r\n\r\n .nl2go_class_14_grey2 {\r\n color: #D6D6D6;\r\n " + " font-family: Arial, Helvetica, sans-serif;\r\n font-size: 14" + "px\r\n }\r\n\r\n .nl2go_class_14_grey2_b {\r\n color: #D6D6D6;\r" + "\n font-family: Arial, Helvetica, sans-serif;\r\n font-size: " + "14px;\r\n font-weight: 700\r\n }\r\n\r\n .nl2go_class_16_blue {" + "\r\n color: #41B8FF;\r\n font-family: Arial, Helvetica, sans-s" + "erif;\r\n font-size: 16px\r\n }\r\n\r\n .nl2go_class_16_grey1 {" + "\r\n color: #636363;\r\n font-family: Arial, Helvetica, sans-s" + "erif;\r\n font-size: 16px\r\n }\r\n\r\n .nl2go_class_16_grey1_b" + " {\r\n color: #636363;\r\n font-family: Arial, Helvetica, sans" + "-serif;\r\n font-size: 16px;\r\n font-weight: 700\r\n }\r\n" + "\r\n .nl2go_class_18_white_m {\r\n color: #ffffff;\r\n fo" + "nt-family: Arial, Helvetica, sans-serif;\r\n font-size: 18px;\r\n " + " font-weight: 500\r\n }\r\n\r\n .nl2go_class_25_black_b {\r\n " + " color: #303030;\r\n font-family: Arial, Helvetica, sans-serif;\r\n " + " font-size: 25px;\r\n font-weight: 700\r\n }\r\n\r\n a[x-" + "apple-data-detectors] {\r\n color: inherit !important;\r\n tex" + "t-decoration: inherit !important;\r\n font-size: inherit !important;\r\n " + " font-family: inherit !important;\r\n font-weight: inherit !i" + "mportant;\r\n line-height: inherit !important;\r\n }\r\n\r\n .n" + "o-show-for-you {\r\n border: none;\r\n display: none;\r\n " + " float: none;\r\n font-size: 0;\r\n height: 0;\r\n " + " line-height: 0;\r\n max-height: 0;\r\n mso-hide: all;\r\n " + " overflow: hidden;\r\n table-layout: fixed;\r\n visibili" + "ty: hidden;\r\n width: 0;\r\n }\r\n \r\n \r\n .nl2go_preheader { display: none !important; mso-hide: all !important; mso-line-height-rule: exactly; visibility: hidden !important; line-height: 0px

the database is the same (I linked to productive database) - and the application is the same too. Any idea whether "release"-mode or published makes some difference? Or maybe you need some more information? I don't get any good exception message i can work with... is there a logging with maybe some more information?
Even if I just have a few words in the template, it fails.

Edit: when publishing with debug, it works. with release it doesnt...