The System.Linq namespace is missing even with a reference to System.Core.Dll

When I open the Asp Net website in Visual Studio 2010, the properties say β€œTarget Framework 3.5,” however, when I try to use the Linq namespace, the compiler complains about it.

"The type or namespace name" var "could not be found (are you missing the using directive or assembly references?)"

"The Linq namespace type or name does not exist in the System namespace (do you miss the assembly reference?)"

I manually referenced some dll to fix my problem, but still failed.

<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.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 

Help?: -)

+6
linq assemblies
source share
2 answers

If you can't even use var , this suggests that it doesn't even use the correct version of the C # compiler. (You can use var even when targeting .NET 2.0, if you use the C # 3 or C # 4 compiler.) I would focus on working with it first.

Is it possible that you are working in IIS but have not configured it accordingly? It might be worth taking a look at the configuration of your site around this side and maybe restarting aspnet_regiis.

+5
source share

I just fixed a similar problem by adding the targetFramework="4.0" attribute to the compilation element in web.config

Modified corresponding snippet:

 <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> </compilation> 
+2
source share

All Articles