Click here to Skip to main content
15,906,766 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi guys.

Having a bit of an issue with the error below I keep getting when running my code.

Error:
Value cannot be null. Parameter name: source

StackTrace:
at System.Linq.Queryable.Any[TSource](IQueryable`1 source, Expression`1 predicate)
at ietCCHPluginsCampaign.ViewModels.EditCampaign.EditCampaignViewModel.RefreshScheduleTypes() in D:\Trunk\Projects\CCH\Plugins.Campaign\iet.CCH.Plugins.Campaign\ViewModels\EditCampaign\EditCampaignViewModel.vb:line 415
at ietCCHPluginsCampaign.ViewModels.EditCampaign.EditCampaignViewModel.OnViewLoaded(Object view) in D:\Trunk\Projects\CCH\Plugins.Campaign\iet.CCH.Plugins.Campaign\ViewModels\EditCampaign\EditCampaignViewModel.vb:line 281
at Caliburn.Micro.Screen.<>c__DisplayClass12.<AttachView>b__11(Object , RoutedEventArgs )

Source of this error comes from following code:
Model.Schedules.Any(Function(x) x.Name = EachScheduleType.Name AndAlso x.Id = EachScheduleType.Id)


Does anyone have any ideas where the root of the problem may lie? I'm not sure if it's a Linq error or what.

Thanks in advance.
Posted
Updated 25-Oct-18 15:10pm
v2

When writing Linq you typically use Lamdba expressions

Model.Schedules.Any( x => x.Name == EachScheduleType.Name && x.Id == EachScheduleType.Id)
 
Share this answer
 
Comments
Shrimpersfan 29-Dec-10 10:59am    
Hi Mark

By using Function(x) x.name... etc, I am indeed using a lambda expression.
[no name] 29-Dec-10 11:10am    
Yes of course. Meaning that it may help to narrow the problem by using a standard approach.
Firt you need to make sure EachScheduleType is not null.

You can then change your lambda to
x.Name == (EachScheduleType.Name??string.empty) AndAlso x.Id == (EachScheduleType.Id??string.empty)).

I've assumed id is a string here.
 
Share this answer
 
Comments
Shrimpersfan 29-Dec-10 11:14am    
Hi Abhinav.

Both properties are strings yes.

I can confirm that EachScheduleType is not null and it's value is being set.

I have modified the lambda but am receiving the same error message as above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900