Unable to read cshtml from compiled project.
See original GitHub issueI’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:
- Created 3 years ago
- Comments:14 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@georgeemr Can you try RazorLight-2.0.0-rc.3? I plan one last fix before official release.
@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).