FluentValidation: Could not load type 'FluentValidation.DependencyInjectionExtensions' after upgrading to latest version
FluentValidation version
12.0.0
ASP.NET version
9.0.5
Summary
I’m also receiving the same error as mentioned in #2314 with it all in one project rarther than seperate clean architecture style.
Program.cs has the following lines to load fluent validation
builder.Services.AddValidatorsFromAssemblyContaining<Program>();
builder.Services.AddFluentValidationAutoValidation(config =>
{
config.DisableDataAnnotationsValidation = true;
});
builder.Services.AddFluentValidationClientsideAdapters();
the csproj has the following reference packages
<PackageReference Include="FluentValidation" Version="12.0.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.0.0" />
downgrading it back to 11.11.0 resolves the error straight away
Steps to Reproduce
upgrade FluentValidation.DependencyInjectionExtension and FluentValidation packages to 12.0.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (8 by maintainers)
Ok I found the issue here and pushed out a
11.3.1release of FluentValidation.AspNetCore with a fix.Thanks for the reproduction @madhon. I’ve tested the fix with your sample project and confirmed it works correctly, but please give it a try to confirm.
@KirkMunroSagent this should sort the issue for you too.
There was a particular method being called that no longer exists in FV 12, my own test projects didn’t catch this due to how they were set up. A new testing target into FluentValidation.AspNetCore’s automated tests to now cover compatibility with FV 12.
That’s correct
There’s no replacement for FluentValidation.AspNetCore and we recommend using manual validation within asp.net projects as the auto validation pipeline has too many limitations, which I’ve made several posts about (summarised here: https://github.com/FluentValidation/FluentValidation/issues/1960) but the package is still useable as a lot of people have dependencies on it so there’s no need to remove it if you are still relying on it. There are some third party alternatives that implement auto validation via an action filter instead of the validation pipeline which may be of interest too