Using service.Gateway inside a Task or outside a service

The gateway provides a decoupled way to invoke services, where the same generic interface can be used to call either internal or external services. The Service Gateway docs describes it in more detail.

But it’s not clear what the cause of your issue is, it’s suggests it’s failing trying to resolve a dependency from ASP.NET Core IOC, perhaps you’re trying to resolve a request scoped dependency in a background thread which you shouldn’t do when executing outside of the request context.

The latest v5.4.1 pre-release packages on MyGet are now have source-link enabled maybe you can use it to debug which dependency is the cause of the issue.