Antaris / RazorEngine

Open source templating engine based on Microsoft's Razor parsing engine
http://antaris.github.io/RazorEngine
Other
2.14k stars 577 forks source link

Views referencing RazorGenerator templates work in debugger only #19

Closed korggy closed 11 years ago

korggy commented 12 years ago

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

Antaris commented 12 years ago

It should add references to any assembly that is currently loaded into the running AppDomain. Will investigate how to manually add assembly references in a clean/consistent way. Might be through the ITemplateServiceConfiguration mechanism.