18

I can compile and test my .NET 4.0 web application just fine within Visual Studio 2010. If, however I point my local IIS to the folder containing the application, I get the following error:

Compiler Error Message: CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
Source Error:
Line 388:                <add namespace="System.ComponentModel.DataAnnotations" />
Line 389:                <add namespace="System.Configuration" />
Line 390:                <add namespace="System.Linq" />
Line 391:                <add namespace="System.Text" />
Line 392:                <add namespace="System.Text.RegularExpressions" />

Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config    Line: 390 

How is it that the web.config from the framework won't compile for me?

I have found similar problems on the web and most just say 'add this reference...', but it can't be the right thing to edit the default web.config -- can it?

nickd
  • 3,951
  • 2
  • 20
  • 24
  • Specify how you're pointing your local IIS to the folder? Are you doing a proper deployment of the web project to IIS? – The Evil Greebo Jun 27 '11 at 17:01
  • Do you have this line in that file? `` (System.Linq should be in System.Core) – Rup Jun 27 '11 at 17:02
  • 1
    @Greebo I've tried both publishing to a folder and just pointing IIS at my project folder. Neither works. – nickd Jun 27 '11 at 17:19
  • 1
    Ok. If I add that assembly reference to my applications web.config, I can move on to a new and exciting error. Curious, I created a standard MVC3 app and published it. It too failed as above. I can keep adding assembly references to everything, but *what's going on*!! – nickd Jun 27 '11 at 17:53
  • Have you checked your Application Pool's .NET Framework version? – Smur Jun 27 '11 at 19:37

3 Answers3

56

This worked for me. Have this assemblies in the web.config file

<system.web>
   <compilation debug="true">
      <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
   </compilation>
</system.web>
Peter B
  • 22,460
  • 5
  • 32
  • 69
Jamal
  • 726
  • 5
  • 5
23

I think you need to add the assemblies below in your web.config -

<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

You will get System.Linq in core assembly

Sachin Shanbhag
  • 54,530
  • 11
  • 89
  • 103
0

If you have a website, asp.net needs proper references to be able to compile it. A web application would not need that.

There are some assemblies referenced in the machine.config, some might be missing depending on your code, you can add them to machine.config or the root web.config.

Rez.Net
  • 1,354
  • 2
  • 19
  • 28