views:

44

answers:

2

Using Visual Studio 2008, and I'm trying to use some of the .net Framework 3.5 utilities - specifically Extension Methods.

However when I try and get to things in the System.Runtime.CompilerServices namespace, the required .Extension namespace is unavailable.

If I go to "add reference" and look for System.Core - the required library for this functionality - it's in the list but is greyed out and unavailable, as are all the other 3.5 libraries.

I have the 3.5 framework installed on my machine. Indeed many of the libraries are being loaded through web.config. Anyone know what's going on here and how I can fix it?

+6  A: 

You need to set the project to the correct target framework version (in the project properties).

Note that compiler features (such as declaring and using extension functions) is not dependent on the selected framework version, since those are independent of the CLR version (framework versions 2.0-3.5 uses the same runtime).

Lucero
Hi - I checked the properties but couldn't see a relevant setting. Sorry to be dumb but could someone point me exactly where it is, please?
Matt Thrower
For libraries and WinForms applications, right-click on the project, properties, then "Application" tab, then "Target Framework:" dropdown. For web sites look at daRoBBie's answer.
Lucero
Sorry, found it - but it's set to 3.5 ...
Matt Thrower
OK - I can't find anything in the application tab. The setting I'm looking at is in compiled > advanced compile options > target framework
Matt Thrower
If it is there is no reason why you shouldn't be able to add the reference to the 3.5 assemblies. Try again after saving the project with the 3.5 target framework set.
Lucero
Ah, got it. There was a rogue project in the solution still set to 2.0 = changed that and now it's working okay. Thanks.
Matt Thrower
Perfect, thanks for the feedback. Now may be a good time to accept an answer. ;-)
Lucero
Done :) Thanks again.
Matt Thrower
+1  A: 

Hi,

  • Right-click on your web application (and all other projects)
  • Goto the compile tab.
  • Click on advanced compile options
  • Set the target framework to ".NET Framework 3.5"
daRoBBie