gpt4 book ai didi

asp.net - RazorEngine 3.6.3 无法从 'string' 转换为“RazorEngine.Templated.ITemplateKey”

转载 作者:行者123 更新时间:2023-12-02 10:04:37 25 4
gpt4 key购买 nike

我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com