Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing type or namespace name

Tags:

c#

asp.net

This is an odd one, not one I've come across before. My project complies and runs fine if I have my classes in the root folder (Not in App_Code).

As soon as I move them into the App_Code folder then it will compile, but running it will bring up the old

CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

I don't understand how moving the class(es) to the App_Code folder causes the whole thing to fall apart there?

Project target is .Net 4 on VWD 2010 Express

like image 881
Psytronic Avatar asked Feb 26 '23 20:02

Psytronic


2 Answers

You have to modify the web.config file of your web application to make it compile and use .net 3.5 (or maybe higher in your case):

<system.web>
  <compilation>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
  </compilation>
</system.web>

<system.codedom>
  <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <providerOption name="CompilerVersion" value="v3.5" />
      <providerOption name="WarnAsError" value="false" />
    </compiler>
  </compilers>
</system.codedom>
like image 145
Matthias Avatar answered Mar 04 '23 11:03

Matthias


I had the exact same problem. The answer for me was to set Local Copy to True in the Properties Window for System.Data.Linq.

like image 40
BlooSki Avatar answered Mar 04 '23 10:03

BlooSki