Closed NVentimiglia closed 9 years ago
Well the problem is the following: RazorEngine compiles the templates to ".cs" files and then to ".dll" assembly files and then loads and executes them. Sadly the CLR doesn't allow unloading the ".dll" files and they are locked by the system, so we can't delete them either.
RazorEngine tries to work around this by spinning up another AppDomain, collects the files which need to be deleted later on and waits for the current AppDomain to unload (so everything is deleted after app shutdown). Sadly this "workaround" doesn't work with the default AppDomain.
Alternatively there is a RazorEngine feature to load the raw bytes instead of the assembly file, this completely shuts down any isolation and debugging and is therefore not always usable.
To get back to your question: Every app launch 5 temporary files will be written and not deleted when RazorEngine is used from the default AppDomain.
Hope this answers your question.
Thanks.
I am confused about the app domain / temporary files logic. Why do I need to worry about this ?
For my use case what should I do ?