Antaris/RazorEngine

The name 'model' does not exist in the current context

Closed this issue · 4 comments

hi, I am trying to use RazorEngine in my project and enable intellisense.
My template is very simple and both compilation and rendering work fine.
However, the very moment I add @inherits RazorEngine.Templating.TemplateBase<MyNamespace.MyClass> to the top, I get two things:

  • intellisense starts working in VS2022
  • compilation fails with a gigantic exception:
RazorEngine.NetCore: Errors while compiling a Template.
Please try the following to solve the situation:
  * If the problem is about missing/invalid references or multiple defines either try to load
    the missing references manually (in the compiling appdomain!) or
    Specify your references manually by providing your own IReferenceResolver implementation.
    See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details.
    Currently all references have to be available as files!
  * If you get 'class' does not contain a definition for 'member':
        try another modelType (for example 'null' to make the model dynamic).
        NOTE: You CANNOT use typeof(dynamic) to make the model dynamic!
    Or try to use static instead of anonymous/dynamic types.
More details about the error:
 - error: (14, 18) The name 'inherits ' does not exist in the current context

any idea?

Any more info on this? Getting same.

I ended up dumping RazorEngine and moving to a simpler html templating one instead.

Which one?

https://github.com/scriban/scriban . My scenario is very simple, I don't really need a lot of functionalities. It's basically a simple report, nothing fancy.