我有一个自定义库项目,其中包含多个Razor
HTML文件以及Nancy
个模块。每当我打开 * .cshtml 文件时,Intellisense
都会发出以下警告:
ASP.NET runtime error: Could not load file or assembly 'System.Web.Razor...'
......虽然它在那里并在app.config
中宣布。我已使用ILSpy
反映了该dll,并显示它没有任何可能未正确加载的其他依赖项。
我该怎么办?
图书馆参考
的app.config
<configSections>
<section name="razor" type="Nancy.ViewEngines.Razor.RazorConfigurationSection, Nancy.ViewEngines.Razor" />
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5">
<buildProviders>
<add extension=".cshtml"
type="Nancy.ViewEngines.Razor.BuildProviders.NancyCSharpRazorBuildProvider, Nancy.ViewEngines.Razor.BuildProviders" />
</buildProviders>
</compilation>
</system.web>
<razor disableAutoIncludeModelNamespace="false">
<assemblies>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="Captivate.Core.Host.Web" />
</assemblies>
<namespaces>
<add namespace="System" />
<add namespace="System.Linq" />
<add namespace="Captivate.Core.Host.Web" />
</namespaces>
</razor>
<system.web.webPages.razor>
<pages pageBaseType="Nancy.ViewEngines.Razor.NancyRazorViewBase">
<namespaces>
<add namespace="System"/>
<add namespace="System.Linq"/>
<add namespace="Nancy"/>
<add namespace="Nancy.ViewEngines.Razor" />
<add namespace="Captivate.Server.Host.Web"/>
</namespaces>
</pages>
</system.web.webPages.razor>
<runtime>
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
为了进行测试,我还创建了一个web.config
并将相关部分复制到其中,但这也无济于事。