我正在将其中一个项目从.net内核3.1迁移到.net 6,其中一个项目不是构建和抛出这个错误。
ConfigureServicesExtensions.cs(62,22):CS1061 'IServiceCollection‘不包含“装饰”的定义,也找不到接受'IServiceCollection’类型的第一个参数的可访问扩展方法‘IServiceCollection’(您缺少使用指令还是程序集引用?)
请参见下面的代码示例,它在从.net 3.1升级到6.0后出现故障。
private static void RegisterCommandHandlers(IServiceCollection serviceCollection)
{
//Scruptor package : https://andrewlock.net/using-scrutor-to-automatically-register-your-services-with-the-asp-net-core-di-container/
serviceCollection.Scan(scan => scan.FromAssemblyOf<ICommand>()
.AddClasses(classes => classes.AssignableTo(typeof(ICommandHandler<>))
.Where(_ => !_.IsGenericType))
.AsImplementedInterfaces()
.WithTransientLifetime());
serviceCollection.Decorate(typeof(ICommandHandler<>), typeof(CommandHandlerLoggingDecorator<>));
}发布于 2022-08-24 11:18:51
如果您的包是最新的,那么您可以尝试如下:
发布于 2022-08-24 11:28:21
https://stackoverflow.com/questions/73471721
复制相似问题