I have a wcf service hosted in a website in IIS and I seem to have this issue. In my web.config I have this:
I had no Linq methods on my Controller (Count, Where, toList, etc...). Adding the namespace:
using System.Linq;
fixed the problem for me. Maybe will help someone in the future...
the problem is you didn't add
debug="true|false" targetFramework="4.0"
in compilation tag.
The solution for me was to:
Go to: Tools > Nuget Package Manager > Manage NuGet Packages for Solution
Install the System.Linq package.
Sometimes it "disappears" just for the fun of it. If you don't need it just delete it.
Else right click your website in the solution explorer and add a reference to it.
I solved this problem by adding the System.Linq
namespace to the namespaces in the Views\Shared\Web.config
file, e.g, as below, 2nd from the bottom, above the WebApplication1
namespace.
Note, this is in the Web.config
in the Views
folder and is not the web site's main 'Web.config`.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="System.Linq" />
<add namespace="WebApplication1" />
</namespaces>
</pages>
</system.web.webPages.razor>
Do you have a code file in your site with either Imports System.Linq
(VB) or using System.Linq;
(c#)?
Seems like the simplest answer is that it is a typo. Maybe the namespace should be corrected to System.Data.Linq
.
Edit: System.Linq should be a valid namespace, as it "provides classes and interfaces that support queries that use Language-Integrated Query (LINQ)." (http://msdn.microsoft.com/en-us/library/system.linq.aspx). It is also imported by default in the system-level web.config.
So, not sure what is happening here if it is not related to my suggestion above. Maybe something wrong in your machine.config or system-level web.config?
Edit 2: I find it strange that you adding the System.Core assembly at this level. I believe this is the assembly that includes the System.Linq namespace. Maybe removing it would help?
Edit 3:
System.Linq
is imported by default in the machine-level web.config. You can remove the line in your code file.