【问题标题】:Razorengine "Unable to compile template. Check the Errors list for details."Razorengine “无法编译模板。请查看错误列表了解详细信息。”
【发布时间】:2011-11-17 09:14:14
【问题描述】:

我正在使用“Razorengine”从 cshtml 模板生成电子邮件正文。 在调试模式(VS 2010)下运行应用程序时一切正常。 模板渲染得很好,模型中的所有数据都按需要插入。

但是当我发布应用程序时。到我的本地 IIS 服务器(win 7 pro)我收到错误“无法编译...” 当我发布到实时 IIS 服务器(在线主机)时,我收到另一个错误(“'RazorEngine.Razor' 的类型初始化程序引发了异常。”)

cshtml模板以

开头
@inherits "RazorEngine.Templating.TemplateBase <Ebits.EnrolmentLCMT.Core.boekingBeheer.resumeBoekingObject>

它包含引用模型的样式表、html 和 razor 标记

这是我在我的代码中调用的:

resumeBoekingObject resumeBoeking = boekingBeheer.getBoekingResume(boeking, taal);
string mailBodyTemplate = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("../htmlPages/confirmMailTemplate.cshtml"));
string mailBodyTekst = Razor.Parse<resumeBoekingObject>(mailBodyTemplate, resumeBoeking);

!!我确信该模板已被很好地阅读,因为我在邮件中将其用作 bodytekst。

任何想法。

非常感谢

【问题讨论】:

    标签: asp.net-mvc razor templating


    【解决方案1】:

    对于您的实时 IIS 服务器,您的部署中可能缺少 MVC3 DLL(我猜是 System.Web.Razor.dll)。检查 GAC (C:\Windows\assembly) 是否存在它在错误的未发布部分中列出的文件,并检查您的 BIN 目录是否存在丢失的文件。

    我今晚遇到了类似的问题,在这里找到了相关信息:http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx

    【讨论】:

      猜你喜欢
      • 2016-01-03
      • 1970-01-01
      • 2018-09-25
      • 1970-01-01
      • 1970-01-01
      • 2018-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多