Errors While Compiling a Template

It seems like every other week I’m getting this error when trying to kick off Postal jobs to be emailed to users…

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:

warning: (0, 0) Assuming assembly reference ‘System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ matches ‘System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’, you may need to supply runtime policy

error: (87, 9) The type ‘System.Object’ is defined in an assembly that is not referenced.
You must add a reference to assembly ‘System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.
Temporary files of the compilation can be found in (please delete the folder): C:\Windows\TEMP\RazorEngine_pptvmztl.try

My web.config looks like this…

system.web
compilation debug=“true” targetFramework=“4.5.2”
httpRuntime targetFramework=“4.5”
customErrors mode=“Off”
error statusCode=“404” redirect="~/Error/Index"
error statusCode=“403” redirect="~/Error/Index"
error statusCode=“401” redirect="~/Error/Index"
error statusCode=“500” redirect="~/Error/Index"
customErrors
pages
namespaces
add namespace=“Kendo.Mvc.UI”
namespaces
pages
system.web
runtime
assemblyBinding xmlns=“urn:schemas-microsoft-com:asm.v1”
dependentAssembly
assemblyIdentity name=“System.Web.Optimization” publicKeyToken=“31bf3856ad364e35”
bindingRedirect oldVersion=“1.0.0.0-1.1.0.0” newVersion=“1.1.0.0”
dependentAssembly
dependentAssembly
assemblyIdentity name=“WebGrease” publicKeyToken=“31bf3856ad364e35”
bindingRedirect oldVersion=“0.0.0.0-1.6.5135.21930” newVersion=“1.6.5135.21930”
dependentAssembly
dependentAssembly
assemblyIdentity name=“System.Web.WebPages” publicKeyToken=“31bf3856ad364e35”
bindingRedirect oldVersion=“0.0.0.0-3.0.0.0” newVersion=“3.0.0.0”
dependentAssembly
dependentAssembly
assemblyIdentity name=“System.Web.Mvc” publicKeyToken=“31bf3856ad364e35”
bindingRedirect oldVersion=“0.0.0.0-5.2.3.0” newVersion=“5.2.3.0”
dependentAssembly
dependentAssembly
assemblyIdentity name=“Antlr3.Runtime” publicKeyToken=“eb42632606e9261f” culture=“neutral”
bindingRedirect oldVersion=“0.0.0.0-3.5.0.2” newVersion=“3.5.0.2”
dependentAssembly
dependentAssembly
assemblyIdentity name=“Newtonsoft.Json” publicKeyToken=“30ad4fe6b2a6aeed” culture=“neutral”
bindingRedirect oldVersion=“0.0.0.0-10.0.0.0” newVersion=“10.0.0.0”
dependentAssembly
dependentAssembly
assemblyIdentity name=“RazorEngine” publicKeyToken=“9ee697374c7e744a” culture=“neutral”
bindingRedirect oldVersion=“0.0.0.0-3.10.0.0” newVersion=“3.10.0.0”
dependentAssembly
assemblyBinding
runtime