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

浪尽此生 提交于 2019-12-01 04:48:00
Kit

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.

larsmoa

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!