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.