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