3

While trying to use LINQ in a .NET 2.0 Windows Forms project I got:

Namespace or type specified in the Imports 'System.Linq' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases

In both the lines that reference the following namespaces:

System.Linq;
System.Xml.Linq;

How could I get these namespaces to work on .NET 2.0 without referencing an external DLL or anything?

4 Answers 4

8

You can't. They were introduced in .NET 3.5.

I don't know of any implementations of LINQ to XML for .NET 2.0 (unless you use a Mono assembly - I assume Mono supports it). There's LINQBridge if you want LINQ to Objects in .NET 2.0, although of course that goes against your "no external libraries" requirement.

Sign up to request clarification or add additional context in comments.

Comments

1

Supposably you can use LINQ in a .NET 2.0 application if you use the 3.0 compiler and include the Mono LINQ implementation. I have no idea how to do this, myself, and I'm pretty sure it means referencing an external DLL. However, .NET applications reference external DLLs all the time, so I wouldn't worry about that.

Update: There's something called LINQBridge which may provide what you need.

Comments

1

LINQ is not avaliable in .NET Framework 2.0. It was introduced in 3.5.

Comments

0

Reference System.Core (I suggest you find it in a .NET 3.5 install).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.