I have a few questions:
Where are you placing this Lambda? Assign activity or somewhere else?
The error says it is a Write Line. What is inside the Write Line activity?
Your lambda looks ok to me, so it must depend on how you are using it.
Message: Activity ‘1.3: VisualBasicValue’ cannot access this public location reference because it is only valid for activity ‘1.9: VisualBasicValue<IEnumerable>’. Only the activity which obtained the public location reference is allowed to use it.
Exception Type: System.InvalidOperationException
RemoteException wrapping System.InvalidOperationException: Activity ‘1.3: VisualBasicValue’ cannot access this public location reference because it is only valid for activity ‘1.9: VisualBasicValue<IEnumerable>’. Only the activity which obtained the public location reference is allowed to use it.
at System.Activities.InlinedLocationReference.ValidateAccessor(ActivityContext context)
at System.Activities.InlinedLocationReference.GetLocationForRead(ActivityContext context)
at System.Activities.ActivityContext.GetValueCore[T](LocationReference locationReference)
at System.Activities.ActivityContext.GetValue[T](LocationReference locationReference)
at lambda_method(Closure , KeyValuePair2 ) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.Count[TSource](IEnumerable1 source) at lambda_method(Closure , ActivityContext ) at Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context) at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity1 expressionActivity)
at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor) at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath) at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate)
at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
if the error comes only at the write line, then just try things slower, use a regular IF condition and two write lines, so you can see where the error is…
From what I remember last time I tried to do this, the problem isn’t the Lambda itself, it’s just that standard LINQ (what’s powering the Where statement) doesn’t work with variables because the query is precompiled
@Zoul Using IEnumerable as a Type is wrong I guess, Since I in IEnumerable stands for Interface, and interface can’t be used as a Data, I guess this was the reason, Even I had encountered that problem before