5

Found this error just after upgrading the .NET framework to 4.7.2:

System.Web.HttpCompileException: some.cshtml(95): error CS0012: The type 'IEnumerable<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.'

Where should I add the reference?

MiguelSlv
  • 14,067
  • 15
  • 102
  • 169

1 Answers1

8

Found at at github. Add the following to the web.Config file:

<compilation debug="true" targetFramework="4.7.2" >
  <assemblies>
    <add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/>
  </assemblies>
</compilation>
MiguelSlv
  • 14,067
  • 15
  • 102
  • 169
  • What do you mean by repro app? – MiguelSlv Jul 18 '18 at 23:46
  • The app which can reproduce the issue(or the steps to reproduce the issue). Also what the version of VS are you using? – mattfei Jul 19 '18 at 16:22
  • This makes alot of sense. The error came during web compilation, and this fixed the issue for me. Thanks! – James White Nov 10 '18 at 13:42
  • This just saved me - even though I'm running a later version of VS that handles this locally, the build server we are running on is using an older version of msbuild where this is still needed to be hand added. – ATrimeloni Jan 18 '21 at 22:04