Coo*_*eze 9 asp.net-mvc templates razor razorengine asp.net-core
我正在尝试将一些现有代码从MVC5迁移到MVC6,我对这个特定代码有困难:
Engine.Razor.RunCompile(File.ReadAllText(emailTemplatePath), "emailTemplateKey", typeof (EmailViewModel), emailViewModel);
Run Code Online (Sandbox Code Playgroud)
我收到以下运行时错误:
MissingMethodException: Method not found: "Void Microsoft.AspNet.Razor.CodeGenerators.GeneratedClassContext.set_ResolveUrlMethodName(System.String)". in RazorEngine.Compilation.CompilerServiceBase.CreateHost(Type templateType, Type modelType, String className)
Run Code Online (Sandbox Code Playgroud)
我在MVC5中使用的原始代码是从这里获取的.如果无法将上述代码转换为使用MVC6,那么另一种优雅的电子邮件模板方式是什么?
显然,类发生了变化GeneratedClassContext- 该属性ResolveUrlMethodName不再存在,因此MissingMethodException. 看起来ParserContext类也发生了变化,因为访问OnError事件处理程序会引发相同的异常。
事实上,它是缺少的属性的设置器丢失(请原谅表达式!),它作为一个方法,导致了异常。绝对准确,但有些误导,除非您还记得这一点。
这里有一个非常相似的问题(以及替代解决方案的一个很好的答案!):RazorEngine and MVC 6 beta 7。
| 归档时间: |
|
| 查看次数: |
1796 次 |
| 最近记录: |