Visual Studio 2015 无法识别 web.config 中为 Razor 导入的命名空间

Visual Studio 2015 doesn't recognize imported namespaces in web.config for Razor

我有一个包含大量 .cshtml(WebPages,而非 MVC)文件的网站项目,并且我在我的 web.config 文件中定义了一组通用名称空间,如下所示

<system.web.webPages.razor>
  <pages pageBaseType="Composite.AspNet.Razor.RazorFunction">
    <namespaces>
      <add namespace="DinArv.Forms"/>
      <add namespace="DinArv.Web"/>
    </namespaces>
  </pages>
</system.web.webPages.razor>

安装 VS 2015 RTM 后,web.config 中定义的命名空间中存在的类型突然出现 'The type or namespace ... could not be found' 错误,而 Resharper 似乎没有问题。我仍然可以正常浏览页面,并且在构建网站时没有构建错误。在我的 Visual Studio 2013 中,Intellisense 正常工作。

如果我在 .cshtml 文件中显式导入命名空间而不是 web.config,VS 2015 也很满意,但我真的不想那样做。

出了什么问题,我该如何解决?

几个小时后,我无意中发现了似乎可以解决问题的方法。我的分区组是这样定义的,VS 2013没问题

<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
  <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
</sectionGroup>

只要我向这样的类型添加版本号,VS 2015 中的 Intellisense 就会亮起。 Grrrrr ....真是浪费时间,但希望这可以节省其他人的时间。

<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="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>