Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure PreserveCompilationContext is set to true #537

Open
JozefGula opened this issue Nov 14, 2023 · 1 comment
Open

Make sure PreserveCompilationContext is set to true #537

JozefGula opened this issue Nov 14, 2023 · 1 comment

Comments

@JozefGula
Copy link

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

@michael-freidgeim-webjet

The following section in .csproj works for me

<PropertyGroup>
   <!--https://github.com/toddams/RazorLight/issues/203#issuecomment-403503671-->
   <!--https://github.com/toddams/RazorLight/blob/f72686e421a2894090c60a944471e10c1aa6a35d/README.md#im-getting-cannot-find-compilation-library-when-i-deploy-this-library-on-another-server-->
   <PreserveCompilationContext>true</PreserveCompilationContext>
 </PropertyGroup>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants