System.Security.VerificationException after installing VS 2012

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

After this step, all the projects that were correct stopped working (already compiled or still built VS2010).

Dozens of places throw an exception: System.Security.VerificationException. This exception also comes from the .NET 3.5 or .NET 4 library. It throws an exception in the XAML InitializeComponents, etc.

What is it? Why does installing a new structure violate all existing projects?

How to solve the problem without erasing VS2012 and .NET 4.5?

Thanks for the suggestions.

0
source share
3 answers

The root of the problem (which affects only 32 bits) is that if the constructor has any program thread (at the IL level), before calling the base / this constructor, the code will check the validation incorrectly. There are some relatively common types used in WPF that have ?: Operations in the arguments to their base / this calls, so you just can't use these specific constructors. I see that this does not work on Lazy and ObservableCollection. Both of these types have some constructors that do not include a thread, so working around changes constructor calls to use versions without parameters. Another scenario (the one that comes with FluentValidation) is that the C # compiler inserts a stream when you have lambdas in your constructor. This works to make lambda actual methods instead.

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

+1
source

I got the same exception and narrowed it down to unit tests that used FluentValidation. It turned out that my test project is built as x86, and it needs to be x64.

To fix this, right-click your project and select Properties. In the left pane, select Build and set Platform Target: to Any Processor

0
source

Are you using the link to FluentValidation.dll? If so, take a look at this post I created yesterday. This may help. VerificationException Problem

0
source

Source: https://habr.com/ru/post/923043/


All Articles