{"record":{"id":"ff423787f9e4a930","repo":"dotnetcore/CAP","slug":"unable-to-resolve-actual-subscriber-type-for-service-service","errorCode":null,"errorMessage":"Unable to resolve actual subscriber type for service: {service.ServiceType.FullName}","messagePattern":"Unable to resolve actual subscriber type for service: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs","lineNumber":127,"sourceCode":"                    continue;\n\n                detectType = service.ImplementationType ?? service.ServiceType;\n                if (!subscribeTypeInfo.IsAssignableFrom(detectType))\n                    continue;\n\n                actualType = service.ImplementationType;\n                if (actualType == null && service.ImplementationFactory != null)\n                {\n                    // Resolve instance produced by factory to inspect runtime type\n                    var instance = scopeProvider.GetRequiredService(service.ServiceType);\n                    actualType = instance?.GetType();\n                }\n            }\n\n            if (actualType == null)\n            {\n                // Consistent error message for diagnostic purposes\n                throw new InvalidOperationException($\"Unable to resolve actual subscriber type for service: {service.ServiceType.FullName}\");\n            }\n\n            var serviceTypeInfo = service.ServiceType.GetTypeInfo();\n            results.AddRange(GetTopicAttributesDescription(actualType.GetTypeInfo(), serviceTypeInfo));\n        }\n\n        return results;\n    }\n\n    protected virtual IEnumerable<ConsumerExecutorDescriptor> FindConsumersFromControllerTypes()\n    {\n        var executorDescriptorList = new List<ConsumerExecutorDescriptor>();\n\n        var types = Assembly.GetEntryAssembly()!.ExportedTypes;\n        foreach (var type in types)\n        {\n            var typeInfo = type.GetTypeInfo();\n            if (Helper.IsController(typeInfo)) executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo));","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/dotnetcore/CAP/blob/e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs#L109-L145","documentation":"A generic diagnostic guard raised while scanning DI services for ICapSubscribe implementations: for a registered service that matches the subscriber interface, CAP could not determine the concrete subscriber type. This happens when the service was registered by interface only (ImplementationType == null) and either has no implementation factory or the factory-resolved instance was null — so the runtime type needed to discover [CapSubscribe] methods is unknown.","triggerScenarios":"Thrown at src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs:127 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register subscriber classes by their concrete implementation type (e.g. services.AddTransient<OrderSubscriber>()) so ImplementationType is available.","If registering via factory, make sure the factory returns a non-null instance whose runtime type actually implements the subscriber interface.","Avoid registering the interface type alone (services.AddTransient<ISubscriber, ...> patterns where only ServiceType is set); register the implementation class directly."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e52b8508e54cdb7a9ce7f9fec03d9ea8ad2710fb","analyzedAt":"2026-09-14T14:46:34.677Z","contentChangedAt":"2026-09-14T14:46:34.677Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}