FluentValidation 3.4.6 Destabilize the runtime VerificationException

589 Views Asked by At

I'm using FluentValidation 3.4.6, and the target framework of my project is .net 4. I've checked my solution thoroughly to ensure there are no references to older versions of FluentValidation.

I believe this version of FluentValidation has a work-around for a reflection bug introduced in .NET 4.5, however I'm still getting a VerificationException, as described here http://elegantcode.com/2012/08/23/net-4-5-operation-could-destabilize-the-runtime-yikes/

VerificationException is thrown at this point:

MyValidator : AbstractValidator<MyObj>

ctor {
     RuleFor(x => x.SomeProperty).Equal(true);
}

at FluentValidation.Resources.LocalizedStringSource.CreateFromExpression(Expression`1 expression, IResourceAccessorBuilder resourceProviderSelectionStrategy) in c:\projects\FluentValidation\src\FluentValidation\Resources\LocalizedStringSource.cs:line 66
at FluentValidation.Validators.PropertyValidator..ctor(Expression`1 errorMessageResourceSelector) in c:\projects\FluentValidation\src\FluentValidation\Validators\PropertyValidator.cs:line 46
at FluentValidation.Validators.EqualValidator..ctor(Object valueToCompare, IEqualityComparer comparer) in c:\projects\FluentValidation\src\FluentValidation\Validators\EqualValidator.cs:line 37
at FluentValidation.DefaultValidatorExtensions.Equal[T,TProperty](IRuleBuilder`2 ruleBuilder, TProperty toCompare, IEqualityComparer comparer) in c:\projects\FluentValidation\src\FluentValidation\DefaultValidatorExtensions.cs:line 143
at MyValidator..ctor() in MyValidator.cs:line 22
3

There are 3 best solutions below

0
On

I was able to run outside the debugger and eventually narrowed it down to intell-trace. Disable intelli-trace if you hit this issue in 3.4.6.

0
On

I also seemed to get around this by adding FluentValidation* to the list of excluded modules in the intellitrace settings (while keeping both events and call info). This was using version 3.4.6 of FV.NET.

0
On

I set Intellitrace to "IntelliTrace events only" and that prevented this issue for me in VS2010.