2017-05-08 14 views
1

nopcommerce에서 플러그인을 만드는 동안 RazorEngine을 사용하는 데 문제가 있습니다.RazorEngine 동적으로 cshtml에 추가

public override void OnActionExecuted(ActionExecutedContext filterContext) 
{ 
    var m = filterContext.Result as ViewResultBase; 
    string newTag = @"@using Nop.Plugin.Misc.Helper.Extensions; @using Nop.Web.Framework.ViewEngines.Razor; 
    <div class='inputs date-of-birth'/ <label>@T('Account.Fields.DateOfBirth'):</label></div>"; 
    var res = "Hello World"; 
    if (m != null) 
    { 
    var model = m.Model as RegisterModel; 
    var service = Engine.Razor; 
    service.AddTemplate("templateRegister", newTag); 
    service.Compile("templateRegister"); 
    res = service.Run("templateRegister", null, model); 
    filterContext.HttpContext.Response.Write(res); 
    } 
} 

그러나 컴파일 및 실행하는 동안, 나는이 오류가 발생했습니다 : 다음 OnActionExecuted에
내 소스 코드는 가능하면

RazorEngine.Templating.TemplateCompilationException: 'Errors while compiling a Template. Please try the following to solve the situation: * If the problem is about missing/invalid references or multiple defines either try to load the missing references manually (in the compiling appdomain!) or Specify your references manually by providing your own IReferenceResolver implementation. See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details. Currently all references have to be available as files! * If you get 'class' does not contain a definition for 'member': try another modelType (for example 'null' to make the model dynamic). NOTE: You CANNOT use typeof(dynamic) to make the model dynamic! Or try to use static instead of anonymous/dynamic types. More details about the error: - error: (36, 79) Too many characters in character literal Temporary files of the compilation can be found in (please delete the folder): C:\Users\Chegini.h\AppData\Local\Temp\RazorEngine_tfr2i1nu.3fl The template we tried to compile is: ------------- START ----------- @using Nop.Plugin.Misc.NchShamsiDate.Extensions; @using Nop.Web.Framework.ViewEngines.Razor;

@T('Account.Fields.DateOfBirth'):

가, 나 조언을 주시기 바랍니다!

답변

1

문제는 @T('Account.Fields.DateOfBirth')와 함께, 그것은 큰 따옴표 @T("Account.Fields.DateOfBirth")

필요