Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Web.HttpCompileException:The type '<>' is defined in an assembly that is not referenced

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?

like image 911
MiguelSlv Avatar asked Jul 18 '18 10:07

MiguelSlv


People also ask

Is defined in assembly that is not referenced?

When you get this error, it means that code you are using makes a reference to a type that is in an assembly, but the assembly is not part of your project so it can't use it.

How to fix error CS0012?

You could resolve this CS0012 by compiling with /reference:cs0012b. dll;cs0012a. dll , or in Visual Studio by using the Add Reference Dialog Box to add a reference to cs0012a. dll in addition to cs0012b.


1 Answers

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>
like image 122
MiguelSlv Avatar answered Oct 29 '22 04:10

MiguelSlv