I am having trouble with making Unity play nice with the new Fakes framework (formerly pex & moles)
When I tried to create fakes of the unity interception library, it caused my unit test to run fine when debugging, but breaks with an
InvalidProgramException - Common Language Runtime detected an invalid program.
The question is why? Why the different behavior in debug vs. release? The unit test pass, when debugging, but breaks with the above exception when I choose to run it, instead.
If I had to guess (never personally combined interception with fakes) I'd say you've got two frameworks that are both fiddling with stuff at an IL level, and that just can't end well.
Fakes works by (going from shady memory here) creating a duplicate "shim filled" variant of the assembly you're faking, and unity interception does IL weaving on the interception points - mix the two of those together and I'm not surprised that it's created an invalid sequence of IL.
Fixing it? Oof...don't use Fakes on any assembly you're performing interception on? Rely on more traditional mocking frameworks in those cases.