seesharper/LightInject.Microsoft.DependencyInjection

The version 2.0.8 throw System.InvalidOperationException with identityServer4

Closed this issue ยท 3 comments

Hi, I just updated from 2.0.5 to 2.0.8 but when I debug I get this error:

System.InvalidOperationException
  HResult=0x80131509
  Message=No storage mechanism for resources specified. Use the 'AddInMemoryIdentityResources' or 'AddInMemoryApiResources' extension method to register a development version.
  Source=IdentityServer4
  StackTrace:
   at Microsoft.AspNetCore.Builder.IdentityServerApplicationBuilderExtensions.TestService(IServiceProvider serviceProvider, Type service, ILogger logger, String message, Boolean doThrow)
   at Microsoft.AspNetCore.Builder.IdentityServerApplicationBuilderExtensions.Validate(IApplicationBuilder app)
   at Microsoft.AspNetCore.Builder.IdentityServerApplicationBuilderExtensions.UseIdentityServer(IApplicationBuilder app)
   at OemTrack.WebApi.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceFactory) in D:\Repositories\WHO\oem-tracks-backend\src\OemTrack.WebApi\Startup.cs:line 150

The previous version of LightInject.Microsoft.DependencyInjection worked with IdentityServer4 without issues.

I am using
LightInject 5.1.10
LightInject.Microsoft.DependencyInjection 2.0.8
IdentityServer4 2.2.0
netcoreapp2.1

Try adding these options (ContainerOptions)

options.DefaultServiceSelector = serviceNames => serviceNames.SingleOrDefault(string.IsNullOrWhiteSpace) ?? serviceNames.Last();

options.EnablePropertyInjection = false;

It worked! Thank you very much.

Great