tags:

views:

32

answers:

3

Hi,

I've been scratching my head for what seems like ages. I'm sure its really simple to fix but I can't see it.

I have a class in App_Code that uses a bit of Linq.

var siteMap = SiteMapWrapper.BuildSiteMap(true);
var currentTopLevelParent = siteMap.Single(s => s.IsActive);
if (currentTopLevelParent != null)

I've developed this locally and all works fine. When I transfer to IIS hosting the same class fails to compile. I receive:

does not contain a definition for 'Single' and no extension method 'Single' 
accepting a  first argument of type 'SiteMapWrapper' could be found (are you 
missing a using directive or an assembly reference?)

I confirmed that the virtual dir is running .NET 2.0 as it should. I also confirmed that the correct assemblies are being loaded in the web.config.

<compilation debug="true">
  <assemblies>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  </assemblies>
</compilation>

I've tried adding namespaces directives in web.config also but no luck. Can anyone think of anything else to try?

Many thanks.

A: 

Add using System.Linq; to the top of the .cs file.

Also, make sure that SiteMapWrapper implements IEnumerable<T>.

EDIT: I didn't notice that it works on the local machine.
Make sure that the server has the correct versions of all of the dependent assemblies.

SLaks
A: 

LINQ actually requires .NET 3.0 (3.5 is better), not 2.0. Make sure the AppPool is configured appropriately.

RickNZ
A: 

I think you will find that the server does not have 3.5 installed.

Gregory