0
    
    
        
                    suresht created
                    
                    
                    
                
                - ABP Framework version: v8.3.0
- UI Type: Angular
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace:
* An exception was thrown while activating CastandCrew.Payroll.Timecard.CapsPay.v1.CapspaytimecardAppService -> CastandCrew.Payroll.Timecard.Queue.v1.AwsSqsHelper.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating CastandCrew.Payroll.Timecard.CapsPay.v1.CapspaytimecardAppService -> CastandCrew.Payroll.Timecard.Queue.v1.AwsSqsHelper.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'CastandCrew.Payroll.Timecard.Queue.v1.AwsSqsHelper' can be invoked with the available services and parameters:
Cannot resolve parameter 'Amazon.SQS.IAmazonSQS sqsClient' of constructor 'Void .ctor(Amazon.SQS.IAmazonSQS)'.
- Steps to reproduce the issue:
- Following is the code in the AbpModule class:
[DependsOn(
    typeof(TimecardDomainModule),
    typeof(TimecardApplicationContractsModule),
    typeof(AbpDddApplicationModule),
    typeof(AbpAutoMapperModule)
    )]
public class TimecardApplicationModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        var configuration = context.Services.GetConfiguration();
        context.Services.AddAutoMapperObjectMapper<TimecardApplicationModule>();
        Configure<AbpAutoMapperOptions>(options =>
        {
            options.AddMaps<TimecardApplicationModule>(validate: true);
            options.AddProfile<TimecardApplicationAutoMapperProfile>(validate: true);
        });
        //Register an instance as singleton
        context.Services.AddSingleton<AmazonSQSClient>(new AmazonSQSClient());
        //Register a factory method that resolves from IServiceProvider
        context.Services.AddScoped<IAmazonSQS>(
            sp => sp.GetRequiredService<AmazonSQSClient>()
        );
    }
}
Following is the code for AwsSqsHelper class which injects IAmazonSQS:
    public class AwsSqsHelper : ApplicationService, IAwsSqsHelper
    {
        #region Class Variables
        private readonly ILogger<CapspaytimecardAppService> _logger;
        private readonly ISettingProvider _settingProvider;
        private readonly IAmazonSQS _sqsClient;
        #endregion
        #region Constructors
        public AwsSqsHelper(
            IAmazonSQS sqsClient)
        {
            _sqsClient = sqsClient;
            _logger = NullLogger<CapspaytimecardAppService>.Instance;
        }
        #endregion
        #region IAwsSqsHelper Implementation
        public async Task<bool> DeleteMessageAsync(string messageReceiptHandle)
        {
            *** Removed for brevity ***
        }
        public async Task<bool> IsQueueReady()
        {
            *** Removed for brevity ***
        }
        public async Task<List<Message>> ReceiveMessageAsync()
        {
            *** Removed for brevity ***
        }
        public async Task<bool> SendMessageAsync(
            string message,
            SqsMessageAttributes messageAttributes)
        {
            *** Removed for brevity ***
        }
        #endregion
    }
Following is the code for CapspaytimecardAppService:
    public class CapspaytimecardAppService : TimecardAppService, ITimecardAppService
    {
        #region Class Variables
        private readonly IAwsSqsHelper _awsSqsHelper;
        private readonly ICapspaytimecardManager _capsPayManager;
        private readonly ILogger<CapspaytimecardAppService> _logger;
        private readonly IObjectMapper _objectMapper;
        private readonly IStringLocalizer<TimecardResource> _stringLocalizer;
        #endregion
        #region Constructors
        public CapspaytimecardAppService(
            IAwsSqsHelper awsSqsHelper,
            IHttpClientFactory httpClientFactory,
            ICapspaytimecardManager capsPayManager,
            IObjectMapper objectMapper,
            IStringLocalizer<TimecardResource> stringLocalizer) : base(httpClientFactory)
        {
            _awsSqsHelper = awsSqsHelper;
            _capsPayManager = capsPayManager;
            _objectMapper = objectMapper;
            _stringLocalizer = stringLocalizer;
            _logger = NullLogger<CapspaytimecardAppService>.Instance;
        }
        internal CapspaytimecardAppService(
            IAwsSqsHelper awsSqsHelper,
            HttpClient httpClient,
            ICapspaytimecardManager capsPayManager,
            ILogger<CapspaytimecardAppService> logger,
            IObjectMapper objectMapper,
            IStringLocalizer<TimecardResource> stringLocalizer) : base(httpClient)
        {
            _awsSqsHelper = awsSqsHelper;
            _capsPayManager = capsPayManager;
            _logger = logger;
            _objectMapper = objectMapper;
            _stringLocalizer = stringLocalizer;
        }
        #endregion
        
            *** Removed for brevity ***
    }
The code was working until I introduced AmazonSQS implementation. Please let me know if you need additional information.
Thanks.
2 Answer(s)
- 
    0Hi, Your code looks to have no problem. Can you share a test project with me? I will check it. shiwei.liang@volosoft.com 
- 
    0Hi, I did more troubleshooting and fixed the issue: Replaced the following: context.Services.AddSingleton<AmazonSQSClient>(new AmazonSQSClient()); with: context.Services.AddSingleton(new AmazonSQSClient(awsRegionEndpoint));Thanks for your assistance. 
 
                                