Exception when searching for validators
See original GitHub issueI haven’t been able to replicate this locally, but have identified this exception from our test envrionment. This appears to happen if a validator isn’t in DI and Blazored FluentValidation scans for it.
I am assuming that this scan is just identifying an existing issue in my solution, but is it possible to handle these errors more gracefully?
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at Blazored.FluentValidation.EditContextFluentValidationExtensions.GetValidatorForModel(IServiceProvider serviceProvider, Object model)
at Blazored.FluentValidation.EditContextFluentValidationExtensions.ValidateField(EditContext editContext, ValidationMessageStore messages, FieldIdentifier fieldIdentifier, IServiceProvider serviceProvider, IValidator validator)
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
validation - Is it a good or bad idea throwing Exceptions ...
I'd go further and saying validation throwing exceptions isn't the best approach; instead return a Boolean and store a list of validation error ......
Read more >Replacing Throwing Exceptions with Notification in Validations
I was recently looking at some code to do some basic validation of some incoming JSON messages. It looked something like this. public...
Read more >If the model is validating the data, shouldn't it throw ...
Controller or presentation layer must decide whether it throws them or it does it's own validations to prevent the exceptions from happening.
Read more >Validation and exception handling
I have quite a few questions when trying out CAF. Please kindly give me some help. 1. I found that it's suggest to...
Read more >Validation and Exception Handling with Spring
Whenever I start implementing a new REST API with Spring, I struggle with the decision of how to validate requests and to handle...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The component wasn’t ever designed to work with that scenario, it was only designed to work with validators registered via DI.
The only way I can see around this is to allow you to pass in a validator instance to use to validate that particular form. I’m not sure how much work that would be. If you could raise that as a separate feature request then it can be looked into.
Correct, if an assembly couldn’t be found and that had the validator in it, then we wouldn’t be able to validate the form and there wouldn’t be any clues to anyone as to why.
That’s interesting. I’ll have a look play around and see if there is anything we can tweak to improve this.