question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RazorLightException: Cant load metadata... PreserveCompilationContext

See original GitHub issue

I’m getting the exception mentioned here: https://github.com/toddams/RazorLight/issues/44

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

But I opened this because none of the suggestions resolved it. Clean/Rebuild wont fix, and adding <PreserveCompilationContext>true</PreserveCompilationContext> wont fix. I am using a Core 2.0 Unit Test app, but that shouldn’t be any different than a simple console app.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
ghostcommented, Dec 6, 2018
  1. Go to project’s folder location
  2. Write “.csproj” then search
  3. Find related csproj file and open it via text editor
  4. Find <PropertyGroup> node.
  5. Add <PreserveCompilationContext>true</PreserveCompilationContext> inside it.
  6. Rebuild the solution.
5reactions
GoodGoodJMcommented, Dec 24, 2017

Where did you add <PreserveCompilationContext>true</PreserveCompilationContext>? Try putting it in “PropertyGroup”.

Like this

  <PropertyGroup>
    ...
    <PreserveCompilationContext>true</PreserveCompilationContext>
    ...
  </PropertyGroup>

I looked at the code in README and put it in ItemGroup, but it was not resolved.

I put it in PropertyGroup and I found it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Can't load metadata reference from the entry ...
This problem is specific to RazorLight. Error: Can't load metadata reference from the entry assembly. Make sure PreserveCompilationContext is ...
Read more >
PreserveCompilationContext not configured by default - .NET
Learn about the breaking change in ASP.NET Core 6.0 where the PreserveCompilationContext property is no longer configured by default.
Read more >
RazorLight
I'm getting "Can't load metadata reference from the entry assembly" exception. Set PreserveCompilationContext to true in your *.csproj file's PropertyGroup ...
Read more >
Tests using razorlight fail - Build/Test Issues
An unhandled exception has occurred while executing the request. RazorLight.Compilation.TemplateCompilationException: Failed to compile ...
Read more >
In my cake script, I can't use CompileRenderAsync.
(Can't load metadata reference from the entry assembly. Make sure PreserveCompilationContext is set to true in *.csproj file. To Reproduce
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found