Dll referencing in CSharpCodeProvider only works when it's set to .NET 2.0?

1.3k views Asked by At

When I set my CSharpCodeProvider class to use .NET 3.5 it errors trying to load certain referenced DLLs:

Line number 0, Error Number: CS0006, 'Metadata file 'System.Linq.dll' could not be found;
Line number 0, Error Number: CS0006, 'Metadata file 'System.Collections.dll' could not be found;

The thing is, if I set it to 2.0 it works, but it can't use LINQ.

Now in other threads there are solutions saying that it's because the DLL isn't in the right place, and offer solutions such as:

typeof(System.Xml.Linq.Extensions).Assembly.Location

To get the location of the Linq location, but due to the way my program works I don't know what DLLs I may need to load. This isn't a problem for external libraries, as the user needs to input where they are anyway, but for System dlls am I able to get their location with just "System.Linq" or "System.Collections"?

1

There are 1 answers

2
Jon Skeet On BEST ANSWER

I'm not aware of System.Collections.dll or System.Linq.dll. Most of LINQ is in System.Core.dll, and the collections are in mscorlib and System.dll IIRC. You need to differentiate between namespaces and assemblies. (You use using directives to import namespaces, and add references to assemblies within the project.)

Which classes are you interested in? Look them up in MSDN to see which assemblies they're in.