Describe the bug
If I do not call Build() from my exec project, I can't use RazorLight. I have this error when I call build() and CompileRenderAsync() from my library:
Failed to compile generated Razor template:
- (3:29) The type or namespace name 'Razor' does not exist in the namespace 'RazorLight' (are you missing an assembly reference?)
- (20:56) The type or namespace name 'TemplatePage<>' does not exist in the namespace 'RazorLight' (are you missing an assembly reference?)
- (20:69) The type or namespace name 'AsbestosEmail' could not be found (are you missing a using directive or an assembly reference?)
- (23:66) 'GeneratedTemplate.ExecuteAsync()': no suitable method found to override
- (4:4) The name 'Layout' does not exist in the current context
- (31:12) The name 'BeginContext' does not exist in the current context
- (32:12) The name 'WriteLiteral' does not exist in the current context
- (33:12) The name 'EndContext' does not exist in the current context
- (34:12) The name 'DefineSection' does not exist in the current context
To Reproduce
Create 2 projects : exec -> dll (call Build() and CompileRenderAsync() and reference RazorLight from gnuget)
Run the project : the error happen when CompileRenderAsyn() is called from the dll.
Temporary Solution
Call Build() from the exec then it's working from the dll even If I re-call build() on a new variable. It's like if the first call initialize some dependencies ....
Consequently I have to add RazorLight in the exec project. For me it's a big problem and can't be done on production :/
Expected behavior
I should be able to use build()/CompileRenderAsyn() without having to call Build() from the executable.
Information (please complete the following information):
OS: Win10
Platform .NET Framework 4.6.2
RazorLight latest version 2.0.0.0 (v4.0.30319) from gnuget
Are you using the OFFICIAL RazorLight package? Yes
Visual Studio version 2019
Additional context
Important point. My executable load the dll dynamically, the dll is not linked in the references.
I have added this in both csproj :
<PreserveCompilationContext>true</PreserveCompilationContext>
Describe the bug If I do not call Build() from my exec project, I can't use RazorLight. I have this error when I call build() and CompileRenderAsync() from my library:
To Reproduce
Temporary Solution
Expected behavior I should be able to use build()/CompileRenderAsyn() without having to call Build() from the executable.
Information (please complete the following information):
Additional context
<PreserveCompilationContext>true</PreserveCompilationContext>
Thank a lot for helping me.