Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

548
Views
RazorLight RazorLight.TemplateNotFoundException: el proyecto no puede encontrar la plantilla con la clave

Estoy tratando de generar HTML basado en un archivo .cshtml, que está incrustado:

 <EmbeddedResource Include="Templates\ReportTemplate.cshtml" />

Sin embargo, de RazorLight siempre obtengo la siguiente excepción:

 RazorLight.TemplateNotFoundException: Project can not find template with key My.Namespace.Application.Templates.ReportTemplate.cshtml at RazorLight.Compilation.RazorTemplateCompiler.CreateRuntimeCompilationWorkItem(String templateKey) at RazorLight.Compilation.RazorTemplateCompiler.OnCacheMissAsync(String templateKey) at RazorLight.Compilation.RazorTemplateCompiler.CompileAsync(String templateKey) at RazorLight.EngineHandler.CompileTemplateAsync(String key) at RazorLight.EngineHandler.CompileRenderAsync[T](String key, T model, ExpandoObject viewBag)

Pero cuando reviso los recursos incrustados, puedo ver claramente el recurso incrustado:

 string[] files = Assembly.GetExecutingAssembly().GetManifestResourceNames();

los files contienen: My.Namespace.Application.Templates.ReportTemplate.cshtml

Aquí está mi código para generar el PDF:

 private async Task<string> RenderRazorTemplate(string key, Type viewModelType, object viewModel) { string[] files = Assembly.GetExecutingAssembly().GetManifestResourceNames(); var engine = new RazorLightEngineBuilder() .UseEmbeddedResourcesProject(Assembly .GetExecutingAssembly()) // Use the Executing Assembly as project that embeds the .cshtml templates .SetOperatingAssembly(viewModelType.Assembly) // Without this, you'll get a Exception saying that the Assembly can't find the AntiForgery.dll .UseMemoryCachingProvider() .Build(); return await engine.CompileRenderAsync(key, viewModel); }

Mis parámetros son: Clave: My.Namespace.Application.Templates.ReportTemplate.cshtml

Estoy usando RazorLight.NetCore3 Versión 3.0.2

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

hola, lograste encontrar una solucion? estoy enfrentando el mismo problema

almost 4 years ago · john obasi Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!