After recently converting to .NET Core I get the following error when trying to authenticate with any of our AuthProviders:
"Error trying to resolve Service 'System.Boolean' from Adapter 'NetCoreContainerAdapter': Object reference not set to an instance of an object."
I am using ServiceStack.Core 5.9.2 on .NET Core 3.1.
Stacktrace
at Funq.Container.GetEntry[TService,TFunc](String serviceName, Boolean throwIfMissing) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Funq\Container.cs:line 490
at Funq.Container.ResolveImpl[TService](String name, Boolean throwIfMissing) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Funq\Container.cs:line 183
at Funq.Container.TryResolveNamed[TService](String name) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Funq\Container.Overloads.cs:line 389
at Funq.Container.TryResolve[TService]() in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Funq\Container.Overloads.cs:line 336
at Funq.Container.<>c__DisplayClass16_0`4.<ReverseLazyResolve>b__1(TArg1 a1, TArg2 a2, TArg3 a3) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Funq\Container.Adapter.cs:line 125
at ServiceStack.Auth.AuthProvider.IsAccountLocked(IAuthRepository authRepo, IUserAuth userAuth, IAuthTokens tokens) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Auth\AuthProvider.cs:line 359
at Authentication.AuthUtilities.HandleSuccessfulTryAuthenticate(CredentialsAuthProvider authProvider, IServiceBase authService, User user, IDbConnection db) in AuthUtilities.cs:line 100
at Authentication.AuthProviders.SgCredentialsAuthProvider.TryAuthenticate(IServiceBase authService, String userName, String password) in SGCredentialsAuthProvider.cs:line 31
at ServiceStack.Auth.CredentialsAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, String userName, String password, String referrerUrl) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Auth\CredentialsAuthProvider.cs:line 120
at ServiceStack.Auth.CredentialsAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, Authenticate request) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Auth\CredentialsAuthProvider.cs:line 98
at ServiceStack.Auth.AuthenticateService.Authenticate(Authenticate request, String provider, IAuthSession session, IAuthProvider oAuthConfig) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Auth\AuthenticateService.cs:line 413
at ServiceStack.Auth.AuthenticateService.Post(Authenticate request) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Auth\AuthenticateService.cs:line 218
Do you have your
SgCredentialsAuthProvider
registered in the IOC? It's only supposed to be added as an AuthProvider in yourAuthFeature
plugin registration.The error suggests you have an autowired Service or a dependency with a public
bool
property or constructor that is trying to be injected with a non-existentbool
dependency that's being called from the IsAccountLocked() method:Judging by its implementation the IOC is trying to resolve each generic argument of the
AccountLockedValidator
from the IOC and failing on thebool
generic argument:Removing the IOC registration of your
SgCredentialsAuthProvider
or ignoring it if you're doing some auto scanning / auto wiring of dependencies should resolve it.