The author of the Calzolari.Grpc.AspNetCore.Validation package explains why upgrading FluentValidation past version 11.4 caused runtime crashes in ASP.NET Core gRPC applications. The root cause was FluentValidation 11.5+ making the IValidator<T> generic parameter contravariant (adding the 'in' keyword), which introduced new internal types that slipped through the package's name-based assembly scanning filter and got registered in the DI container as non-instantiable types. The fix involves five improvements to the AddValidators() method: excluding all types from the FluentValidation assembly itself, filtering out abstract classes, interfaces, and open generic types, adding try/catch around GetTypes() calls, and silently skipping irrelevant types instead of crashing. The updated package (version 10.1.0) is now available on NuGet.

4m read timeFrom anthonygiretti.com
Post cover image
Table of contents
ContextThe SymptomRoot CauseThe FixConclusion

Sort: