Antaris/RazorEngine — Issue #19: Views referencing RazorGenerator templates work in debugger only
Author: korggy
Created: 2012-01-28 18:19:40+00:00
State: open

I'm trying to use RazorEngine against views that reference templated helpers that have been pre-compiled using RazorGenerator. When I do so, everything works 100% fine as long as I have the debugger attached (i.e. run with F5) but when I run standalone (i.e. run with Ctrl-F5) I get the exception below. I suspect that the assembly that RazorEngine is generating for my view doesn't include a reference to the System.Web.WebPages assembly -- is there a way that I can specify a list of assemblies to be included when my view is compiled?

Unhandled Exception: RazorEngine.Templating.TemplateCompilationException: Unable to compile template. The type 'System.Web.WebPages.HelperResult' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
'.

Other compilation errors may have occurred. Check the Errors property for more information.
at RazorEngine.Compilation.DirectCompilerServiceBase.CompileType(TypeContextcontext)
at RazorEngine.Templating.TemplateService.CreateTemplateType(String razorTemplate, Type modelType)
at RazorEngine.Templating.TemplateService.CreateTemplateType(String razorTemplate)
at RazorEngine.Templating.TemplateService.CreateTemplate(String razorTemplate)
at RazorEngine.Templating.TemplateService.Parse(String razorTemplate)
at ConsoleApplication2.Program.Main(String[] args) in d:\temp\ConsoleApplication2\Program.cs:line 20