views:

66

answers:

2

Hi,

Whenever I add a lambda expression (in the following form) to my wpf project, I get an error. The errors are nothing to do with the expression, but they arrive every time I add one.

here is my latest:

using ( LeisureServiceClient client = ServiceFactory.Instance.GetLeisureService() )
{
    client.Execute( ServiceFactory.Instance.ConnectionDetails, new MoveBasketItemsToAccountCommand()
    {
        BasketItemIDs = bisList.ToList().ConvertAll<Guid>( bis => bis.ID )
    } );
}

This seems perfectly valid to me, this gives the following compile error, highlighting client from client.Execute(...).

Error 43: The type 'System.Windows.DependencyObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.

this code is nothing to do with a DependancyObject. Regardless, System.Windows is referenced in the .cs file, which also contains:

public class PointOfSaleViewModel : DependencyObject

which is quite happy to compile when the lambda expression is removed.

now, to add confusion... this is fine:

ServiceFactory.Instance.ShiftDataRefreshedEvent += ( s, e ) =>
{
    Account = new ObservableCollection<BasketItemSummary>( ServiceFactory.Instance.CurrentContact.Account );
    Basket = new ObservableCollection<BasketItemSummary>( ServiceFactory.Instance.Shift.OpenCurrentContact.Basket );
};

so, it's not the lambda expression itself that's causing the error, I'm out of ideas as to why this isn't compiling, and pretty keen to get some input before my head explodes.

Update

the alternate syntax suggested by a colleague

BasketItemIDs = bisList.ToList().ConvertAll( delegate( BasketItemSummary basketItem ) { return basketItem.ID; } )

also fails, giving the same compilation error.

A: 

You need to add a reference to the dll in your project: right click on project, choose add reference.

klausbyskov
+1  A: 

It sounds to me like BasketItemSummary (or one of the properties) exposes this dependency on the public API - perhaps it is a base-class for the type. Simply: add the missing reference as it instructs.

Marc Gravell
System.Windows is in the presentationFramework.dll/windowBase.dll, which are already referenced in the application, can't see that there is just a System.Windows in the [add reference] browser so I assume this is right. using System.Windows; is also at the top of the .cs file.
Dead.Rabit