0

I use in work VS2010, and as a test for moving forward I install VS2012.

After this step all projects which were correct before stops working (already compiled, or still builded by VS2010).

Dozen of places rises an exception: System.Security.VerificationException. This exception also goes from library on .NET 3.5 or .NET 4. It rises an exception in XAMLs InitializeComponents, etc.

What is it? Why installation of new framework breaks all exisiting projects?

How to solve it without erasing VS2012 and .NET 4.5?

Thanks for suggestions.

Eugene
  • 301
  • 1
  • 4
  • 13

3 Answers3

1

The root of the issue (which only impacts 32 bit) is that if a constructor has any program flow (at the IL level) before invoking a base/this constructor, the code will improperly fail verification. There are some relatively common types used in WPF that have ?: operations in the arguments to their calls to base/this, so you simply can't use those particular constructors. I've only see it fail on Lazy and ObservableCollection. Both those types have some constructors that don't include flow, so the work around is changing constructor calls to use the parameter-less versions. The other scenario (the one that shows up with FluentValidation) is that the C# compiler inserts flow when you have lambdas in your constructor. That work around is to make the lambda's actual methods instead.

Just in case it's not obvious from my explanation, we (the CLR team) are aware of the problem and are actively working on a solution.

Kevin Frei
  • 396
  • 2
  • 7
0

I got the same exception and narrowed it down to unit-tests which were using FluentValidation. It turned out that my test-project where build as x86 and it needed be x64.

To fix this, right-click your project and choose Properties. In the left pane choose "Build" and set "Platform target:" to "Any CPU"

Daniel
  • 21
  • 2
  • I am getting the same problem. I already target Any CPU. However I'm also running on an x64 platform so my code is jitted to 64-bit. Does FluentValidation only support x86? – Eric J. Aug 16 '12 at 15:21
  • Yap... it fixes only several projects. The main problem that we have a lot of 3rd party projects which is native or already build for x86. – Eugene Aug 17 '12 at 05:34
0

Do you use the reference to FluentValidation.dll? If yes take a look at this post I created yesterday. This could help VerificationException problem