I'm trying to use RazorEngine from VB, and I'm stuck on an issue with the configuration.
I have this is my web.config...
<configSections>
<section name="razorEngine" type="RazorEngine.Configuration.RazorEngineConfigurationSection, RazorEngine" requirePermission="false"/>
</configSections>
<razorEngine>
<templateServices>
<add name="myCustomTemplateService" language="VisualBasic"/>
</templateServices>
</razorEngine>
As far as I can see from the documentation this looks correct. However when I try to run my code, I get the following error...
"Unrecognized element 'add'."
It doesn't like this bit...
<add name="myCustomTemplateService" language="VisualBasic"/>
Any thoughts would be greatly appreciated. I'm stumped. All the examples I've found online appear to show that I'm doing it the correct way.
Update:
I've changed my Web.config to...
<razorEngine>
<templateServices>
<service name="service" language="VisualBasic" />
</templateServices>
</razorEngine>
The config no longer errors, however RazorEngine appears to be ignoring it, as it gives the following error when I try to parse a template...
Unable to compile template. Unexpected character '$'
Looks like you're reading pre-v3 docs on how to configure that stuff in the web.config. Unfortunately, I don't see any documentation for RazorEngine configuration for verson 3 and up. But you can read the source directly on GitHub, and it looks like they've changed those config elements around. Here's the source on the templateServices element. It looks like, at a minimum, child elements are no longer added using an "add" node. They are now added using a "service" node (AddItemName = "service"
).