Resolve generic Microsoft.Extensions.Logging.ILogger<T> with Unity - get InvalidCastException
问题 I am trying to register a generic ILogger (from Microsoft.Extensions.Logging, not from Serilog) in Unity (version 4). I've got the following class: public class MyClass { private readonly Microsoft.Extensions.Logging.ILogger<MyClass> _logger; public MyClass(Microsoft.Extensions.Logging.ILogger<MyClass> logger) { _logger = logger; } } And the following Unity registrations and test: // Arrange IUnityContainer container = new UnityContainer(); // provider from Serilog.Extensions.Logging nuget