Thursday, October 8, 2015

The type Expression<> is defined in an assembly that is not referenced.

I recently had to upgrade an older ASP.NET MVC Web Application over to MVC 5.

Since Visual Studio 2015 was recently released, I decided to use VS 2015 to perform the upgrade.

Well, after I had gone through the standard operations of upgrading all of the files in the project, I was suddenly faced with the following error message when attempting to use any Html Helpers such as @Html.LabelFor or @Html.TextBoxFor.  All of the other Html Helpers were working and intact, but these were not showing up in Visual Studio Intellisense!

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

Well, I already had a reference to System.Core in my project, so why was this error still appearing?
I decided to do some more testing and I discovered that NEW ASP.NET MVC projects did not face this problem!!  It was only an issue with my upgraded project!!

Fortunately, I came across this StackOverflow article which points out a resolution:

As it turns out, I needed to add some assembly references to my Web.config file as follows:

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

Once I did that, my Intellisense for these Html Helpers started working again!  Woo hoo!


  1. Thanks for the help! Saved me from pulling my hair out. Not sure how this was taken out of my web.config, but who cares, it is working now :)

  2. thank you so much, you save my day

  3. Not resolved for me :(