c# - wf4 An activity can only access its own implementation variables -


i have activity variables (which c# expressions), not able read values.

    public collection<variable> variables { get; } = new collection<variable>();      protected override void doexecute(nativeactivitycontext context)     {         var x = variables.firstordefault(...).get(context);     } 

resulting in

activity '1.1: myactivity' cannot access variable  because declared @ scope of activity '1.1: myactivity'.   activity can access own implementation variables. 

i attempted expose them via cachemetadata

    protected override void cachemetadata(nativeactivitymetadata metadata)     {         metadata.setimplementationvariablescollection(variables);     } 

and results in

exception <system.notsupportedexception:  expression activity type 'csharpvalue`1' requires compilation in order run.   please ensure workflow has been compiled. 

my variables c# expressions , compiled

var wwfactivity = activityxamlservices.load(xamlreader, new activityxamlservicessettings {compileexpressions = true}); 

enter image description here

i able hack around with

var var = context.datacontext.getproperties()["variablename"]; var value = var.getvalue(context.datacontext) whatever; 

without overriding cachemetadata method, feels lil weird;


Comments