How can I prevent a VerificationException when running a test with attached debugger?

后端 未结 3 641
刺人心
刺人心 2021-01-12 20:32

Whenever I run either of the following unit test with a debugger attached, I get a VerificationException inside FluentValidation code at this point (will post w

相关标签:
3条回答
  • 2021-01-12 21:12

    I experienced the same issue and found TypeMock 6.0 to be the culprit. By disabling TypeMock Isolator (menu TypeMock -> Disable TypeMock Isolator) I got rid of the problem. This of course breaks any TypeMock dependent test.

    Note that adding FluentValidation to IntelliTrace exceptions does not resolve the issue when TypeMock is the problem.

    0 讨论(0)
  • 2021-01-12 21:28

    Ok, I've got it. First I'd like to acknowledge Jeremy Skinner for working with me to reproduce the problem. His help spurred me to try tweaking my environment further.

    To prevent the problem you either have to disable IntelliTrace in Visual Studio 2010 Ultimate, or you have to add FluentValidation to the list of modules that IntelliTrace should exclude from collecting data. My web searches seem to indicate it's an IntelliTrace bug. Jim Nakashima in his blog post says:

    The issue is that IntelliTrace itself has a bug where methods that have a boolean out parameter in an assembly that is marked as SecurityTransparent will fail when IntelliTrace collection is set to “high” which is the default in the Cloud IntelliTrace scenario.

    You will see this in your own code if you have a method whose signature includes a boolean out parameter and you have set your assembly security to SecurityTransparent.

    I looked at my stack trace and briefly through the FluentValidation source, but didn't see this. I suspect it might be a similar IntelliTrace instrumentation bug relating to LINQ expressions.

    Anyway, here's how to fix the issue:

    1. In VS, select Debug | Options And Settings... | IntelliTrace | Modules
    2. In the following dialog, click Add... and enter FluentValidation into the text box.

    enter image description here

    0 讨论(0)
  • 2021-01-12 21:31

    In my case my Asp.net MVC 3 application had a reference to FluentValidation.dll and FluentValidation.mvc.dll files.

    I removed the references and installed the FluentValidation for MVC 3 using nuget package manager and It worked.

    It downloaded FluentValidation.Mvc version 5.0.0.1

    0 讨论(0)
提交回复
热议问题