小编Mic*_*śka的帖子

无法解析“MediatR.IMediator”类型的服务

我尝试使用 CQRS 制作 .NET Core API,但由于 MediatR 错误而无法构建它:

System.AggregateException: '无法构建某些服务(验证服务描述符时出错'ServiceType: Core.Infrastructure.Domain.Queries.IQueryBus Lifetime: Scoped ImplementationType: Core.Infrastructure.Bus.QueryBus': 无法解析服务在尝试激活“Core.Infrastructure.Bus.QueryBus”时输入“MediatR.IMediator”。)”

我已经为我的 QueryBus 等添加了“AddScope”。这是我的代码(AWS 应用程序):

public class Startup
    {
        public const string AppS3BucketKey = "AppS3Bucket";

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public static IConfiguration Configuration { get; private set; }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddAWSService<Amazon.S3.IAmazonS3>();

            services.AddScoped<IQueryBus, QueryBus>();
            services.AddScoped<IWarehouseRepository, WarehouseRepository>();
            services.AddScoped<IRequestHandler<GetAllWarehouseDepartmentsQuery, IEnumerable<WarehouseDepartmentDto>>, WarehouseQueryHandler>();
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            { …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net cqrs mediatr

6
推荐指数
1
解决办法
5517
查看次数

如何在独立组件appoach中为root导入CommonModule?

我最近启动了新的应用程序,并发现 Angular 团队将默认使用独立方法并最终摆脱模块。所以我决定重写我的应用程序。

但是,我无法在main.ts. 有什么方法可以全局导入它而不是在每个组件中(或通过路由)?

这是我应该可以工作的代码:

// main.ts

import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { importProvidersFrom } from '@angular/core';
import { CommonModule } from '@angular/common';

bootstrapApplication(AppComponent, {
  providers: [importProvidersFrom(CommonModule)],
});
Run Code Online (Sandbox Code Playgroud)
// app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
  standalone: true,
})
export class AppComponent {}
Run Code Online (Sandbox Code Playgroud)
<!-- app.component.html -->

<div *ngIf="true">TEST</div>
Run Code Online (Sandbox Code Playgroud)

我仍然收到错误:

src/app/app.component.html:1:7 - warning NG8103: The `*ngIf` directive was used in the template, but …
Run Code Online (Sandbox Code Playgroud)

angular

6
推荐指数
1
解决办法
4289
查看次数

标签 统计

.net ×1

angular ×1

asp.net ×1

c# ×1

cqrs ×1

mediatr ×1