我正在尝试用这一行编译一个 razor 文件
RazorEngine.Razor.Parse("Hello world");
但它只是抛出
base {System.Exception} = {"Unable to compile template. Source file 'C:\\Windows\\TEMP\\vlu4zahf.0.cs' could not be found\n\nOther compilation errors may have occurred. Check the Errors property for more information."}
错误属性如下所示:
[0] = {error CS2001: Source file 'C:\Windows\TEMP\vlu4zahf.0.cs' could not be found}
[1] = {warning CS2008: No source files specified}
所以没有好的资料。
我正在运行 .NET 4.0 和 Razor Engine 3.2.0.0
更新1
我已在 RazorEngine 中找到此行的错误
Tuple.Create(
compileResult.CompiledAssembly.GetType("CompiledRazorTemplates.Dynamic." + context.ClassName),
compileResult.CompiledAssembly);
最佳答案
这很可能是编译 razor 文件的用户帐户的权限问题。 确保它对 C:\Windows\Temp 具有几乎完全的控制权限
请参阅此处了解背景信息: http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/85f9b330-a938-4afe-a615-db83085e52d2/
关于c# - RazorEngine 解析抛出无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15805434/