Share via


VS2017 The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Question

Friday, March 16, 2018 7:52 PM

Dear All;

I getting an error via *.cshtml followed error **The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. **

I added Web.config file followed tags. But not resolve my problem. 

<compilation debug="true" targetFramework="4.6.1" >
<assemblies>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>

I can compile project but VS2017 intellisense dont work.

All replies (3)

Friday, March 16, 2018 8:11 PM

I getting an error via *.cshtml followed error The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

What you are being told is that you need to install the DLL so that the project can use it doing it via Visual Studio. 

An example where you use the Nuget Console and issue the install command. I believe Nuget will take care of the install and setting reference to the DLL in the project.

https://www.nuget.org/packages/System.Core/


Saturday, March 17, 2018 12:31 PM

try adding the below to the cshtml, to see if that error goes away. Also check under references in your web project if System.Core is available. If it is not available you might want to install the package to your project through Nuget. Right click the project select, managu nuget packages, Search for System.Core and click install.

@using System.Core

Monday, March 19, 2018 9:08 AM

Hi ergatech,

The type 'Expression<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 

There are many reasons for this problem:

  1. Add the related assembly in root web.config, not the web.config in views folder, just as what you've done.
  2. Ensure the version of the .NET framework for the compilation property in web.config is the same as that specified in the project properties.
  3. Ensure the version of the MVC assembly  in the views folder web.config is the same as the MVC assembly you are using in your project.
  4. Restart the project.

For more details, please refer to following articles:

https://stackoverflow.com/a/32221526

https://stackoverflow.com/a/37381294

https://stackoverflow.com/a/31789296

https://forums.asp.net/t/2089626.aspx?bogus+intellisense+error+putting+red+squiggles+all+over+razor+views+

I can compile project but VS2017 intellisense dont work.

About intellisense not working, you can refer to this article:

https://www.c-sharpcorner.com/blogs/how-to-resolve-intellisense-issue-in-visual-studio1

Best Regards,

Daisy