Monday, 12 April 2010

SOLVED: The type or namespace name 'Linq' does not exist in the namespace 'System' - are you missing an assembly reference?

This problem has been cropping up a lot recently - projects will complain of missing namespace's when I open them up and attempt to compile the first time. If this has happened to you then read on for a simple fix.

Scenario

I don't know if this one is a bug in Visual Studio 2010 (Beta 2 and RC1) or something else but recently I have noticed this error cropping up more and more. When I open an existing project it might fail to compile. I have also noticed it happen when I have downloaded a fresh project. Its not something I have pinned down but whenever I see this error:

Error 1 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

I know that the solution is quick and simple.

Solution

To get your compiler back on its feet you simply need to add a reference to System.Core.

  1. Right click on the Bin folder in the Solution Explorer
  2. Choose Add Reference…
  3. Click the .NET tab and scroll down to System.Core
    • If you wait a few moments for the entire list to load you can simply click once on the list and start type System.Core. This will select the right item without you having to scroll and search for it.
  4. Click OK to accept the new reference

Once you have completed this cycle once you will be able to quickly select it by complete Step 1, 2 and then clicking the Recent tab and quickly selecting it from the short list.

14 comments:

Anonymous said...

Does not work! Using Visual Studio 2010 Ultimate and compiling a .net 3.5 website.

bkpro108 said...

thanks so much

Jorge said...

thanks for your help man ;)
it really work

Trey said...

System.Core was shown as a reference for me in VS, but when viewing the .csproj file it was not there. I had to add it manually to fix my issue.

انوش said...

Does not work Using Visual Studio 2010 Ultimate. It says the reference adds automatically in run time.

Anonymous said...

Thank you very much

Anonymous said...

Thanks a lot it helped and was handy... keep up good work.

Rohit Gopidi said...

Thanks a lot, Worked for me !!

Rohit Gopidi said...

Thanks, Worked for me !!

Anonymous said...

I have been experiencing the same problem, it is fine on the local net work, but on the shared network I keep getting the above error. I am using VS2012.
My code is :











Ronak Patel said...

thanks Man !!! ! !
Its Working For Me in VS2008

Ronak Patel said...

thanks Man ...
Its Working For Me In VS2008

Anonymous said...

Its Working For Compiling ..but if you use Union() of Linq its getting Error
"'System.Array' does not contain a definition for 'Union'"

Anonymous said...

Thank you so much for your instructions!!


-->