error while using .UseEmbeddedResourcesProject(System.Reflection.Assembly.GetEntryAssembly())
See original GitHub issuehi I am using razorlight in .net core2.2 MVC web project, i have registered the services of razorlight in the Startup.cs class as shown below
` var engine = new RazorLightEngineBuilder() .UseEmbeddedResourcesProject(System.Reflection.Assembly.GetEntryAssembly()) //.UseFileSystemProject($“{RootPath}\Views”) .EnableDebugMode(true) .UseMemoryCachingProvider() .Build();
services.AddSingleton<IRazorLightEngine>(engine); `
i have also created a generic class that converts my views to string , one of the methods is below
` public async Task<string> GenerateNotificationContent(string messageBody,
string pathToView)
{
var model = new CustomEmailMessageModel
{
MessageBody = messageBody
};
return await razorLightEngine.CompileRenderAsync($"{pathToView}", model);
} `
the views that i want are in the Views folder of the project, so when calling the above method i provide the path to the view that i want e.g Views/Subfolder/View but im getting the below error
RazorLightProjectItem of type RazorLight.Razor.EmbeddedRazorProjectItem with key Views/Subfolder/view.cshtml could not be found by the RazorLightProject of type RazorLight.Razor.EmbeddedRazorProject and does not exist in dynamic templates. See the “KnownDynamicTemplateKeys” and “KnownProjectTemplateKeys” properties for known template keys.
what am i doing wrong
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top GitHub Comments
Can you verify that you set the “Build Action” to “Embedded resource” in the properties of the .cshtml files? I had a similar issue and realized I forgot this step.
Close this as it seems to be something people report when they don’t read the FAQ or exception message