toddams/RazorLight

Make sure PreserveCompilationContext is set to true

JozefGula opened this issue · 0 comments

Hello, can someone help me?

I have an ASP Net 7.0 project with RazorLight 2.3.1. I added "PreserveCompilationContext" to my *.csproj. However, I keep getting this error:

"Can't load metadata reference from the entry assembly. Make sure PreserveCompilationContext is set to true in *.csproj file"

I tried various combinations with PreserveCompilationContext but without success. Nothing in the FAQ solves my problem.

var engine = new RazorLightEngineBuilder()
	.UseEmbeddedResourcesProject(typeof(Program).Assembly, typeof(Program).Namespace)
	.UseMemoryCachingProvider()
	.SetOperatingAssembly(typeof(Program).Assembly)
	.EnableDebugMode(true)
	.Build();

return await engine.CompileRenderAsync("Views.EmailTemplates.Email", model);

Any ideas? Thank you very much