6

非 MVC 環境でRazor Engine ( razorengine.codeplex.com ) を使用しています。ファイルに保存されているテンプレートをコンパイルし@inherits、Intellisense サポートに使用します。

  • RazorEngine アセンブリ
  • カスタム アセンブリ - RazorEngine を参照し、基本クラスとして格納View<>および設定しますView<>
  • Web アプリケーション - RazorEngine、カスタム アセンブリを参照し、.cshtml テンプレート ファイルを含む

すべての cshtml ファイルには、次の@inheritsディレクティブがあります。

@inherits View<SomeModel>

エラーがスローされます。

名前空間ビューの型が見つかりません。アセンブリ参照がありませんか?

私の web.config には、次のエントリが含まれています。

<add namespace="CustomAssembly.NamespaceContainingViewClass" />

<assemblies>これは、 myCustomAssemblyが言及されていない他のエントリと関係があると思います。これは事実ですか?別のアセンブリに含まれているカスタム基本クラスでコンパイルできますか?

ps 私のカスタム アセンブリは厳密な名前が付けられていない 3d パーティのアセンブリを参照しているため、アセンブリの厳密な名前を取得できません...

スタックトレース:

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)
4

2 に答える 2

1

あなたはおそらくあなたの:にかみそりの設定セクションを追加する必要があります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>
于 2011-05-16T15:34:45.497 に答える