I suspect you may have run into a limitation of the built-in Microsoft DI container available in .NET 5 that's used by Umbraco V9, as opposed to LightInject that was available in V8.
The container is swappable for another one that provides additional features in .NET 5, but I don't suppose that's really appropriate for a package - as someone using it in a custom solution may not want that (or may want a different one).
Thanks Andy, seems to be working if I register the generic services using builder.Services.AddSingleton(), and builder.Services.AddUnique() for the services implementing the generic type. So far so good...
Registering an open generic implementation type
Started looking at porting packages and have hit an issue in my composer - this doesn't work anymore (worked fine in 8):
Throws an exception re
Open generic service type x requires registering an open generic implementation type
Advice much appreciated...
My bad - should be using AddScoped, not AddUnique.
I suspect you may have run into a limitation of the built-in Microsoft DI container available in .NET 5 that's used by Umbraco V9, as opposed to LightInject that was available in V8.
The container is swappable for another one that provides additional features in .NET 5, but I don't suppose that's really appropriate for a package - as someone using it in a custom solution may not want that (or may want a different one).
There's some discussion here that might offer options to resolve this.
Andy
Thanks Andy, seems to be working if I register the generic services using
builder.Services.AddSingleton()
, andbuilder.Services.AddUnique()
for the services implementing the generic type. So far so good...is working on a reply...