找不到支持服务 Abp.Zero.Configuration.IAbpZeroConfig 的组件

No component for supporting the service Abp.Zero.Configuration.IAbpZeroConfig was found

我实现了一个自定义的 ExternalLogin,就像 aspnetboilerplate document:

public class MyExternalAuthSource : DefaultExternalAuthenticationSource<Tenant, User>, ITransientDependency
{
    public override string Name
    {
        get { return "MyCustomSource"; }
    }

    public override Task<bool> TryAuthenticateAsync(string userNameOrEmailAddress, string plainPassword, Tenant tenant)
    {

    }
}

我注册为:

public class ImmenseWebModule : AbpModule
{
    public override void PreInitialize()
    {
        Configuration.Modules.Zero().UserManagement.ExternalAuthenticationSources.Add<MyExternalAuthSource>();
    }
}

但是在 运行ning 项目之后我遇到了以下异常:

No component for supporting the service Abp.Zero.Configuration.IAbpZeroConfig was found

当我添加 Abp.Zero.Common.dll 时,我会得到以下错误:

The type 'DefaultExternalAuthenticationSource' exists in both 'Abp.Zero.Common, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null' and 'Abp.Zero, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null'

如果我删除 Abp.Zero.dll 我会得到另一个例外。

项目类型是ASP.Net MVC 5

任何帮助将不胜感激。

更新1:

按如下方式定义绑定后:

<dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>

我遇到了异常:

Can't create component 'Abp.BackgroundJobs.BackgroundJobStore' as it has dependencies to be satisfied.

'Abp.BackgroundJobs.BackgroundJobStore' is waiting for the following dependencies: - Service 'Abp.Domain.Repositories.IRepository`2[[Abp.BackgroundJobs.BackgroundJobInfo, Abp, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' which was not registered.

所以经过一番搜索,我得出的结论是我必须实施 IRepository 并将其注册为(只是为了成为 运行):

public interface ISampleBlogRepository<TEntity, TPrimaryKey> : IRepository<TEntity, TPrimaryKey>
    where TEntity : class, IEntity<TPrimaryKey>
{

}

并注册:

IocManager.IocContainer.Register(Component.For(
                typeof(IRepository<>))
                    .ImplementedBy(typeof(ISampleBlogRepository<>)).LifestyleTransient().Named("IRepositoryImplementation"));
            IocManager.IocContainer.Register(Component.For(
                typeof(IRepository<,>))
                    .ImplementedBy(typeof(ISampleBlogRepository<,>)).LifestyleTransient().Named("IRepositoryOfPrimaryKeyImplementation"));

但不幸的是我遇到了新问题:

Object reference not set to an instance of an object.

和堆栈的一部分:

[NullReferenceException: Object reference not set to an instance of an object.] Abp.Domain.Uow.UnitOfWorkDefaultOptionsExtensions.GetUnitOfWorkAttributeOrNull(IUnitOfWorkDefaultOptions unitOfWorkDefaultOptions, MethodInfo methodInfo) in D:\Github\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkDefaultOptionsExtensions.cs:11 Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) in D:\Github\aspnetboilerplate\src\Abp\Domain\Uow\UnitOfWorkInterceptor.cs:32 Castle.DynamicProxy.AbstractInvocation.Proceed() +443 Castle.Proxies.IRepository2Proxy_1.GetAllListAsync(Expression1 predicate) +155 Abp.Configuration.d__3.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.Zero.Common\Configuration\SettingStore.cs:40 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

为什么这么复杂,我每一步都遇到新的异常。

更新2:

如果我通过 Configuration.BackgroundJobs.IsJobExecutionEnabled = false; 禁用 bg 个作业,我会遇到另一个异常,如下所示:

Can't create component 'Abp.MultiTenancy.TenantCache 2[[x.Web.x.Core.Tenant, x.Web.x.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[MARCO.Web.ImmenseLib.Core.User, x.Web.x.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' as it has dependencies to be satisfied.

Abp.MultiTenancy.TenantCache 2[[x.Web.x.Core.Tenant, x.Web.x.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[x.Web.x.Core.User, x.Web.x.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' is waiting for the following dependencies: - Service 'Abp.Domain.Repositories.IRepository 1[[x.Web.x.Core.Tenant, x.Web.x.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.

[DependsOn(typeof(AbpZeroCommonModule))] 添加到您的模块:

[DependsOn(typeof(AbpZeroCommonModule))]
public class ImmenseWebModule : AbpModule
{
    // ...
}

Method 'ExecuteActionFilterAsync' in type 'Abp.WebApi.Validation.AbpApiValidationFilter' from assembly 'Abp.Web.Api, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

添加这些绑定:AbpCompanyName.AbpProjectName.WebMpa/Web.config#L46-L261

问题 #2494 中提到此绑定有助于:

<dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>