To access environment information from within an activity, you'll need to use the System.Activities.Hosting.SymbolResolver class.
Here's the code to add the symbol resolver to the workflow application:
class Program{ static void Main(string[] args) { WorkflowApplication WFApp = new WorkflowApplication(new Workflow1()); SymbolResolver symbolResolver = new SymbolResolver(); WFApp.Extensions.Add(symbolResolver); symbolResolver.Add("CustomObject", new SymbolUserActivity.MyObject() { MyValue = 1, MyString = "TestString" }); WFApp.Run(); Console.ReadLine(); }}
Here's the code to access the symbol resolver from within an activity:
public sealed class SymbolUser : CodeActivity{ protected override void Execute(CodeActivityContext context) { SymbolResolver symbolResolver = context.GetExtension<SymbolResolver>(); MyObject obj = symbolResolver["CustomObject"] as MyObject; Console.WriteLine(obj.MyString); }}public class MyObject{ public int MyValue { get; set; } public string MyString { get; set; }}