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.i.../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: (574, 62) 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'.
- error: (574, 62) The type 'System.ValueType' 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'.
- error: (574, 62) The type 'System.Collections.Generic.IList`1<T0>' 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'.
- error: (574, 62) The type 'System.Collections.Generic.ICollection`1<T0>' 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'.
- error: (574, 62) The type 'System.IEquatable`1<T0>' 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'.
- error: (574, 62) The type 'System.Collections.Generic.IReadOnlyList`1<T0>' 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'.
- error: (574, 62) The type 'System.Collections.Generic.IReadOnlyCollection`1<T0>' 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'.
- error: (574, 62) The type 'System.Collections.Generic.IEnumerable`1<T0>' 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'.
- error: (574, 62) The type 'System.Collections.IEnumerable' 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'.
- error: (574, 62) The type 'System.Collections.IList' 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'.
- error: (574, 62) The type 'System.Collections.ICollection' 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'.
- error: (574, 62) The type 'System.Collections.IStructuralComparable' 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'.
- error: (574, 62) The type 'System.Collections.IStructuralEquatable' 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'.
- error: (574, 62) The type 'System.Func`2<T0,T1>' 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:\Users\ljohnston\AppData\Local\Temp\RazorEngine_ngbf2fpl.bov
The template we tried to compile is:
[...template snipped...]
List of loaded Assemblies:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll
Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2015\nCrunch.TaskRunner.dll
Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2015\nCrunch.Common.dll
Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll
Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2015\nCrunch.TestExecution.dll
Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll
Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2015\nCrunch.Reflection.dll
Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2015\nCrunch.Module.MSpec.dll
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\20\Companion\Tests\bin\Debug\Companion.Tests.dll
Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll
Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\20\_ncrunchreferences\Machine.Specifications.dll
Loaded Assembly: C:\Users\ljohnston\AppData\Local\Temp\NCrunchDynamicProxy\NCrunch.DynamicProxy_28bd7f517a434bed8220da95814c6cc1_14020.dll
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\25\Companion\bin\Debug\Companion.exe
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\20\_ncrunchreferences\NodaTime.dll
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\20\_ncrunchreferences\Sepialine.Commons.dll
Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Collections.Immutable\v4.0_1.1.36.0__b03f5f7f11d50a3a\System.Collections.Immutable.dll
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\1\Model\bin\Debug\Model.dll
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\7\Presentation\bin\Debug\Presentation.dll
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\20\_ncrunchreferences\CsvHelper.dll
Loaded Assembly: C:\WINDOWS\assembly\GAC_MSIL\nCrunch.TestRuntime\2.16.0.13__01d101bf6f3e0aea\nCrunch.TestRuntime.dll
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\20\_ncrunchreferences\RazorEngine.dll
Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll
Loaded Assembly: D:\Development\NCrunchWorkspace\14020\20\_ncrunchreferences\System.Web.Razor.dll
Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll
at RazorEngine.Compilation.DirectCompilerServiceBase.CompileTypeImpl(TypeContext context)
at RazorEngine.Compilation.DirectCompilerServiceBase.CompileType_Windows(TypeContext context)
at RazorEngine.Compilation.DirectCompilerServiceBase.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.<>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 [...location in our code snipped...]