The following is the generally document way fo doing this:

System.Convert.ToString(Microsoft.XLANGs.Core.Service.RootService.InstanceId);

However, sometimes, for no apparent reason, it won’t compile, or at least shows a “red dot” on the upper right corner of the expression shape, even though it is technically correct. Sometimes if you open it, and close it, or move it and move it back, then the error will go away. But this is a bug, and should not be required.

New alternative way to get the Orchestration InstanceID:

strProcessId = System.Convert.ToString
(YourOrchestrationName 
(Microsoft.XLANGs.BaseTypes.InstanceId));

YourOrchestrationName is the TypeName found in the Orchestration Properties.

This has not caused the “stupid” problem of the compile errors and having to touch the shape, and move it.

Filed under: Orchestrations