Azure / durabletask

Durable Task Framework allows users to write long running persistent workflows in C# using the async/await capabilities.
Apache License 2.0
1.47k stars 287 forks source link

Getting DurableTask.Core.Exceptions.TypeMissingException for all the Orchestrator/Activities #1078

Closed Man2MSFT closed 2 months ago

Man2MSFT commented 2 months ago

Usage flow: Service -> Our common package -> DTF

Scenario: We have created a Wrapper on top of DTF library and added a common functionality which can be use by our different partners, and on our side of package we are initializing orchestrators/activities as shown below (we follow the approach mentioned here Link):

ServiceCollection collection = new ServiceCollection;
collection.AddTransient<ControlFlowOrchestrator>();

var serviceProvider = collection.BuildServiceProvider();
taskHubWorker.AddTaskOrchestrations(new ServiceProviderObjectCreator<TaskOrchestration>(typeof(**ControlFlowOrchestrator**), serviceProvider));

we are facing an issue where we are getting the error while executing the callback, DTF is not able to find the orchestrator.

\<Task ID>: Executing 'PackageName.DurableTask.Orchestrators.ControlFlowOrchestrator' orchestration logic TaskOrchestrationDispatcher-8b76bd8f033b4b289a839c667fb7c8a3-0: Unhandled exception with work item '\<Task ID>': DurableTask.Core.Exceptions.TypeMissingException: Orchestration not found: (PackageName.DurableTask.Orchestrators.ControlFlowOrchestrator, ) at DurableTask.Core.TaskOrchestrationDispatcher.d__22.MoveNext() in C:\source\durabletask\src\DurableTask.Core\TaskOrchestrationDispatcher.cs:line 478

note: When we are trying to register the Orchestrator with default constructors without ServiceCollection, it is working fine and able to resolve the Type.

taskHubWorker.AddTaskOrchestrations(typeof(ControlFlowOrchestrator))

While using dependency injection with ServiceProviderObjectCreator we are not able resolve registered Types. Please help us to resolve this issue.

Man2MSFT commented 2 months ago

@cgillum can you please help us here?

cgillum commented 2 months ago

This sounds like an issue with the ServiceProviderObjectCreator you are using. I suggest following up with the owner of that as I'm not aware of how it works.

Man2MSFT commented 2 months ago

@cgillum Okay, thank you.

We have tried few things and it's working now. Closing this ticket.