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.

Unable to read cshtml from compiled project.

See original GitHub issue

I’m unable to read the cshtml from a compiled dll that net core 3.1 creates when deploy the app.

To Reproduce

string assemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
var metadataReference = Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(Path.Combine(assemblyFolder, "Project.Views.dll"));
                var engine = new RazorLightEngineBuilder()
                 .UseMemoryCachingProvider()
                 .UseEmbeddedResourcesProject(typeof(Program))
                 .AddMetadataReferences(metadataReference)
                 .Build();

string html = await engine.CompileRenderAsync<object>("Views.CV._TheView", Model);

Expected behavior HTML of view

but get message: Project can not find template with key

What do I missing?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jzabroskicommented, Dec 21, 2020

@georgeemr Can you try RazorLight-2.0.0-rc.3? I plan one last fix before official release.

1reaction
maxbanascommented, Nov 24, 2020

@jzabroski I’ve started working on the feature we discussed and created a new issue, #398, so we can stay on topic (and close this issue if you want).

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSHTML file is not compiled anymore
My comment helped so I will write an answer. This error was caused adding to project file from another destination. You were modifying...
Read more >
Changes to cshtml not taking effect in debug mode
cshtml file, save it and refresh to see the changes. I am experiencing that this is not the behavior and after each change,...
Read more >
Razor file compilation in ASP.NET Core
Razor files with a . cshtml extension are compiled at both build and publish time using the Razor SDK. Runtime compilation may be...
Read more >
Render Razor View(.cshtml) to String in .NET Core
In this tutorial, I'm going to render the HTML string for the Invoice from .cshtml. The source code can be found here. Creating...
Read more >
Publishing and deploying a Razor Pages application to IIS ...
The published output includes a .dll file (assembly) with the same name as your project. This is the compiled version of the application, ......
Read more >

github_iconTop Related Medium Post

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