Unable to migrate from RazorEngine: "error: (19, 18) The name 'inherits' does not exist in the current context"
See original GitHub issueI’m currently trying to migrate away from the old RazorEngine
v3.10.0 to RazorEngineCore
v2.2.6. I changed the package and my project compiles. After getting a message related to the @model
directive, I found out it is not supported in the Core version, and that, if one wants to have intellisense, one has to add an @inherits
tag.
However, when I add that in place of the old @model
, I get an exception:
RazorEngine.Templating.TemplateCompilationException : 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: (19, 18) The name 'inherits' does not exist in the current context
I tried both:
@inherits RazorEngineCore.RazorEngineTemplateBase<MyModel>
(which actually gives me red squiggly lines in the editor) as well as@inherits RazorEngine.Templating.TemplateBase<MyModel>
What am I missing?
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
c# - RazorEngine throws 'the name model does not exist in ...
RazorEngine is a custom library built on top of Microsoft's Razor view engine. ... The name 'model' does not exist in the current...
Read more >Custom User Management in ASP.NET Core MVC ...
We will build a small yet practical implementation of Custom User Management in ASP.NET Core MVC with Identity. This will cover most of...
Read more >Error CS0103 The name 'ViewBag' does not exist in the ...
In this case I had a legacy application that I was updating to a more recent platform and this error cropped up quite...
Read more >NancyFX Migration from 0.9 to 0.10
As you try to build the project after upgrade, it would fail because of ... 18) The name 'Url' does not exist in...
Read more >Razor syntax reference for ASP.NET Core
Razor is a markup syntax for embedding .NET based code into webpages. The Razor syntax consists of Razor markup, C#, and HTML. Files...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top 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
@neilgaietto when I was discussing this topic here, we were trying to leverage
RazorEngine.NetCore
due to its higher apparent level of compatibility with the old native libraries. However, we never got it to work 100% and we’ve since actually made the jump and migrated toRazorEngineCore
while making the necessary adjustments to our previous logic. The decision to go withRazorEngineCore
was made while we were still in the initial steps of this process, so we never managed to get a full solution working withRazorEngine.NetCore
.For that reason, I probably won’t be able to help you with your issue. I’d recommend opening an issue in the other repo and/or posting a question to StackOverflow and see if you get any traction there.
@julealgon Any chance you figured out your issue here? I know this issue relates to a different library, but I am running into the exact same issue. My ‘@inherits’ or ‘@model’ isnt working when I upgraded to RazorEngine.NetCore. I’ve been pretty unsuccessful finding a solution so far, and your the first person I’ve seen with the same issue. Any help is appreciated. Thank You!