我的 RazorEngine 版本 3.6.3 有问题 RazorEngine 无法从“字符串”转换为“RazorEngine.Templated.ITemplateKey
”我的代码如下:
var templateServiceConfiguration = new TemplateServiceConfiguration();
templateServiceConfiguration.Namespaces.Add("System.Configuration");
var body = string.Empty;
using (var service = RazorEngineService.Create(templateServiceConfiguration))
{
body = service.RunCompile(emailTemplate.Body, emailTemplate.UniqueName, model: _model, modelType: null, viewBag: null);
}
所以这个方法 service.RunCompile( 第一个参数 ITemplateKey 是什么,但是这个方法也有重载,必须支持我的版本。
请帮忙。
最佳答案
这碰巧使我能够解决我不同但相似的问题。谢谢!
除了使用 Engine.Razor.RunCompile 时,我得到了基本相同的错误消息,如下所示:
Engine.Razor.RunCompile("templateid", templateHtml, null, new { Name = "World" });
文档说您必须只包含 RazorEngine.Templated 命名空间,而我需要同时包含 RazorEngine 和 RazorEngine.Templated。
using RazorEngine;
using RazorEngine.Templating;
关于asp.net - RazorEngine 3.6.3 无法从 'string' 转换为“RazorEngine.Templated.ITemplateKey”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29261175/