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.

error while using .UseEmbeddedResourcesProject(System.Reflection.Assembly.GetEntryAssembly())

See original GitHub issue

hi I am using razorlight in .net core2.2 MVC web project, i have registered the services of razorlight in the Startup.cs class as shown below

` var engine = new RazorLightEngineBuilder() .UseEmbeddedResourcesProject(System.Reflection.Assembly.GetEntryAssembly()) //.UseFileSystemProject($“{RootPath}\Views”) .EnableDebugMode(true) .UseMemoryCachingProvider() .Build();

        services.AddSingleton<IRazorLightEngine>(engine); `

i have also created a generic class that converts my views to string , one of the methods is below

` public async Task<string> GenerateNotificationContent(string messageBody, string pathToView) { var model = new CustomEmailMessageModel { MessageBody = messageBody
};

        return await razorLightEngine.CompileRenderAsync($"{pathToView}", model);
    } `

the views that i want are in the Views folder of the project, so when calling the above method i provide the path to the view that i want e.g Views/Subfolder/View but im getting the below error

RazorLightProjectItem of type RazorLight.Razor.EmbeddedRazorProjectItem with key Views/Subfolder/view.cshtml could not be found by the RazorLightProject of type RazorLight.Razor.EmbeddedRazorProject and does not exist in dynamic templates. See the “KnownDynamicTemplateKeys” and “KnownProjectTemplateKeys” properties for known template keys.

what am i doing wrong

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
JMcConahiecommented, Oct 16, 2022

Can you verify that you set the “Build Action” to “Embedded resource” in the properties of the .cshtml files? I had a similar issue and realized I forgot this step.

0reactions
jzabroskicommented, Oct 16, 2022

Close this as it seems to be something people report when they don’t read the FAQ or exception message

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.Reflection.Assembly.GetEntryAssembly() is null ...
I am developing a web application in visual studio 2010 with target framework - 3.5 I am using a dll (developed by another...
Read more >
Assembly.GetEntryAssembly Method (System.Reflection)
The GetEntryAssembly method can return null when a managed assembly has been loaded from an unmanaged application. For example, if an unmanaged application ......
Read more >
Assembly.GetEntryAssembly() returns null in unit test projects
SetExecuteAssembly is not called. Hence GetEntrypointAssembly() returns null. This is by design. There are multiple workaround people have posted on internet ...
Read more >
Getting Assemblies Is Harder Than You Think In C# – .NET ...
GetAssemblies(), if you have not made a call into a particular assembly, it will not be loaded! Now if you are getting all...
Read more >
System.Reflection.Assembly.Get...
The GetEntryAssembly method can return null when a managed assembly has been loaded from an unmanaged application.
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