问题
I implemented a custom ExternalLogin exactly like 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)
{
}
}
and I registered it as:
public class ImmenseWebModule : AbpModule
{
public override void PreInitialize()
{
Configuration.Modules.Zero().UserManagement.ExternalAuthenticationSources.Add<MyExternalAuthSource>();
}
}
but after running project I crossed with below exception:
No component for supporting the service Abp.Zero.Configuration.IAbpZeroConfig was found
When I added Abp.Zero.Common.dll
I will get below error:
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'
If I removed Abp.Zero.dll
I will get another exceptions.
Project type is ASP.Net MVC 5
any help would be truly appreciated.
UPDATE1:
After defining a binding as below :
<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>
I got the exception:
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.
So after some search I came to this conclusion that I have to implement IRepository
and register it as(just to be run):
public interface ISampleBlogRepository<TEntity, TPrimaryKey> : IRepository<TEntity, TPrimaryKey>
where TEntity : class, IEntity<TPrimaryKey>
{
}
and register it:
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"));
But unfortunately I faced new problem as :
Object reference not set to an instance of an object.
and part of Stack:
[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.IRepository
2Proxy_1.GetAllListAsync(Expression
1 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
Why it is complicated, I faced to new exception in each step.
UPDATE2:
If I disable bg
jobs by Configuration.BackgroundJobs.IsJobExecutionEnabled = false;
I got another exception as below:
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.
回答1:
Add [DependsOn(typeof(AbpZeroCommonModule))]
to your module:
[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.
Add these bindings: AbpCompanyName.AbpProjectName.WebMpa/Web.config#L46-L261
It is mentioned in issue #2494 that this binding helps:
<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>
来源:https://stackoverflow.com/questions/49106683/no-component-for-supporting-the-service-abp-zero-configuration-iabpzeroconfig-wa