I am trying to figure out the internals of the windows workflow foundation. So, we have some software components and we intertwine them in the form of a workflow be it a condition based sequential workflow or a state machine workflow. Now, I am thinking (I may be wrong here) that doesnt the same apply to IoC + Dependency Injection (via Unity or Spring.net). When to use what?? Am I even thinking right??
Not quite sure I understand the question but I will give it a try anyway.
WF doesn't use an IOC container. It uses the ServiceLocator pattern where you add dependencies to the workflow runtime, the service locator, and workflow activities and retrieve these services from the workflow runtime.
A ServiceLocator and IOC pattern are similar and have the same purpose in decoupling dependencies. The apporach is different though in an IOC container pushing dependencies in while a ServiceLocator is used to pull dependencies out.
Hope this answers your question and if not I would try and rephrase the original question.
I was grappling with how to use components provided and serviced by my IOC container from workflows, too. As the other answer states, workflow instances want to use service-locator to pull services from the runtime instead of having the dependencies injected.
An easy way to bridge the gap is to take the dependencies out of your IOC container at the time you are setting up the WF runtime, and then use AddService to put them into the runtime. Your workflows can override OnActivityExecutionContextLoad, and use the GetService method on the service provider to fish them back out of the runtime and plop them into [NonSerialized] public properties on the workflow. You then have access to the services from code activities, etc.
You might also be able to rig up a runtime service that injects dependencies when the workflow instances are activiated.