Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2015 IntelliSense: Assembly Not Referenced Error

I just switched to VS 2015. I have an older MVC 5 app that runs against 4.52. In VS 2013 it's perfectly fine.

In VS 2015 I'm getting red squigglies under my @Html.TextBoxFor() with an error indicating:

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'.

The project builds and runs just fine -- but I am concerned about the IntelliSense error that never happened in VS 2013. Okay, so I try to add the reference to System.Core as recommended in the error above and then I get this error:

A reference to 'System.Core' could not be added. This component is already automatically referenced by the build system.

Again, this is fine in VS 2013.

like image 615
Tom Baxter Avatar asked Jul 23 '15 22:07

Tom Baxter


2 Answers

I had the same issue, but in the mean time I've found the answer:

I had to add the following references to my web.config (add inside the opening system.web tag):

<compilation debug="true" targetFramework="4.5">     <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 also changed the target framework from 4.5.1 to 4.5.

p.s Close and reopen Visual Studio after changing it.

like image 193
Herr Kater Avatar answered Sep 28 '22 04:09

Herr Kater


I have tried most of these, what eventually worked for me was unloading the project, edit the csproj file, and add the following:

<Reference Include="System.Core" /> 
like image 30
Pedro Pedrosa Avatar answered Sep 28 '22 04:09

Pedro Pedrosa