2017-05-08 7 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")

を必要とします
関連する問題