I'm using the Razor Engine (razorengine.codeplex.com) in a non-MVC environment. I compile templates that are stored in files and use @inherits
for intellisense support.
View<>
and sets View<>
as baseclassAll cshtml files have the following @inherits
directive:
@inherits View<SomeModel>
An error is thrown:
The type of namespace View isn't found, are you missing an assembly reference?
My web.config contains the following entry:
<add namespace="CustomAssembly.NamespaceContainingViewClass" />
I think this has something to do with the other entry <assemblies>
, where my CustomAssembly
isn't mentioned. Is this the case? Can I compile with my custom base class which is contained in another assembly?
p.s. I cannot retrieve a strong name for the assembly because my custom assembly references a 3d party assembly which isn't strongly named either...
Stacktrace:
at RazorEngine.Compilation.DirectCompilerServiceBase.CompileType(TypeContext context)
at RazorEngine.Templating.TemplateService.CreateTemplate(String template, Type modelType)
at RazorEngine.Templating.TemplateService.GetTemplate(String template, Type modelType, String name)
at RazorEngine.Templating.TemplateService.Compile(String template, Type modelType, String name)
at RazorEngine.Razor.Compile(String template, Type modelType, String name)
You probably need to add the razor config section to your web.config
:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configSections>
<section name="razorEngine" type="RazorEngine.Configuration.RazorEngineConfigurationSection, RazorEngine" requirePermission="false" />
</configSections>
</configuration>
<razorEngine>
<namespaces>
<add namespace="CustomAssembly.NamespaceContainingViewClass" />
</namespaces>
</razorEngine>