Open Closed

Use blob storing module in .net web api project which is not abp template solution #9727


User avatar
0
imranStem created

I have one .net core web api project which is not abp solution but I want to use the blob storing module with this project. I have created one module in the project as below.

[DependsOn(typeof(NxPBlobStoringAwsModule))]
 public class NxPAipModule : AbpModule
 {
     public override void PreConfigureServices(ServiceConfigurationContext context)
     {
         //context.Services.AddAutoMapperObjectMapper<>();
         base.PreConfigureServices(context);

         Configure<AbpBlobStoringOptions>(options =>
         {
             options.Containers.Configure<DocumentBlobContainer>(container =>
             {
                 container.UseAws(Aws =>
                 {
                     Aws.Region = "eu-west-2";
                     Aws.CreateContainerIfNotExists = true;
                     Aws.UseClientSideEncryption = false;
                     Aws.AccessKeyId = "";
                     Aws.SecretAccessKey= "";
                     Aws.ContainerName = "nxp-staging-1";
                 });
             });
         });
     }
 }

and create the intance of NxPApiModule in program.cs file as below.

using (var application = AbpApplicationFactory.Create<ChurchAipModule>(options =>
 {
     options.UseAutofac();
 }))

This is my NxPBlobStoringAwsModule

[DependsOn(typeof(AbpBlobStoringModule),
 typeof(AbpCachingModule),
     typeof(AbpAutofacModule))]
 public class NxPBlobStoringAwsModule : AbpModule
 {
 }

When I run the project, I am getting below exception on application build.

  • Exception message and full stack trace: System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Volo.Abp.BlobStoring.IBlobContainer Lifetime: Transient ImplementationType: Volo.Abp.BlobStoring.BlobContainer1[Church.Api.DocumentBlobContainer]': Unable to resolve service for type 'Volo.Abp.BlobStoring.IBlobContainerFactory' while attempting to activate 'Volo.Abp.BlobStoring.BlobContainer1[Church.Api.DocumentBlobContainer]'.) (Error while validating the service descriptor 'ServiceType: Church.Api.Services.IShipmentAppService Lifetime: Transient ImplementationType: Church.Api.Services.ShipmentAppService':
  • Steps to reproduce the issue:

10 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • To use the ABP Blob Storing module (such as AWS S3) in a non-ABP .NET Core Web API project, you must ensure that all required dependencies and module registrations are present. The error you are seeing indicates that the BlobStoring provider (e.g., AWS) is not fully registered, specifically the required services for IBlobContainerFactory.

    • In your custom module, you must add a dependency on the AWS Blob Storing provider module. For AWS, this is AbpBlobStoringAwsModule. You must also install the NuGet package Volo.Abp.BlobStoring.Aws and add the module dependency:

    [DependsOn(typeof(AbpBlobStoringAwsModule))]
      public class NxPBlobStoringAwsModule : AbpModule
      {
      }
    
    • In your main module (e.g., NxPAipModule), ensure you also depend on your custom AWS module:
    [DependsOn(typeof(NxPBlobStoringAwsModule))]
      public class NxPAipModule : AbpModule
      {
          public override void PreConfigureServices(ServiceConfigurationContext context)
          {
              Configure<AbpBlobStoringOptions>(options =>
              {
                  options.Containers.Configure<DocumentBlobContainer>(container =>
                  {
                      container.UseAws(aws =>
                      {
                          aws.Region = "eu-west-2";
                          aws.CreateContainerIfNotExists = true;
                          aws.UseClientSideEncryption = false;
                          aws.AccessKeyId = "";
                          aws.SecretAccessKey = "";
                          aws.ContainerName = "nxp-staging-1";
                      });
                  });
              });
          }
      }
    
    • Most importantly, you must ensure that the AWS Blob Storing provider module is initialized by the ABP module system. If you only register your own modules, but not the official provider module, the required services (like IBlobContainerFactory) will not be available, resulting in the error you see.

    • In your Program.cs, when creating the application, make sure you use your main module (NxPAipModule) and that all dependencies are resolved:

    using (var application = AbpApplicationFactory.Create<NxPAipModule>(options =>
      {
          options.UseAutofac();
      }))
      {
          application.Initialize();
          // ... your code
      }
    
    • Double-check that you have installed the following NuGet packages:

      • Volo.Abp.BlobStoring.Aws
      • Volo.Abp.BlobStoring
      • Volo.Abp.Autofac
    • If you still encounter issues, ensure that your DocumentBlobContainer class is defined as:

    using Volo.Abp.BlobStoring;
    
      [BlobContainerName("document-blob-container")]
      public class DocumentBlobContainer
      {
      }
    
    • The key point is that the provider module (AbpBlobStoringAwsModule) must be included in the dependency chain and initialized by the ABP module system.

    Sources:


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    imranStem created

    I am getting following error now.

    System.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Church.Api.Services.IShipmentAppService Lifetime: Transient ImplementationType: Church.Api.Services.ShipmentAppService': Unable to resolve service for type 'AutoMapper.IMapper' while attempting to activate 'Church.Api.Services.ShipmentAppService'.)

    I have added dependency of auto mapper.

    [DependsOn(typeof(NxPBlobStoringAwsModule), typeof(AbpAutoMapperModule))]
    public class ChurchAipModule : AbpModule
    {
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a simple project?

    liming.ma@volosoft.com

    I will check and fix it

    Thanks.

  • User Avatar
    0
    imranStem created

    I sent email

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I didn't receive. Can you send it by https://wetransfer.com/

    Thanks.

  • User Avatar
    0
    imranStem created

    I sent it by wetransfer.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Thanks, I will check it asap.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    What is your email?

    I have changed your project to an abp modular app.

    Thanks.

  • User Avatar
    0
    imranStem created

    imran@spacestem.com

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Sent by https://wetransfer.com/

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 01, 2025, 08:37