I upgraded our software from vs2008/.net 3.5 to vs2010/.net 4.0. All third party libraries (most relevant: nhibernate 2.1.2, spring 1.3.0, nunit 2.5.2) are still compiled using vs2008. When I run the unit tests for the debug build of our software, everything works fine. On the release build, nunit reports exceptions on 33 of 228 tests: System.InvalidProgramException : Common Language Runtime detected an invalid program.
It always happens on the same tests, for both nunit-console and the Resharper 5.0 test runner. When I run them using the Resharper "debug unit-tests" command, all tests pass. It makes no difference whether I run the tests individually or batched. The exception always happens near nhibernate query calls, but I can't say for sure since the release build stack trace is somewhat sparse. It does not depend on the nhibernate bytecode generator, the same exception appears for castle and linfu. Does anyone have an idea how to debug this?