nunit on release build: “Common Language Runtime detected an invalid program.”

柔情痞子 提交于 2019-12-04 07:23:46

This is probably a stupid question: are you sure all of the assemblies are compiled to the same architecture (x86/x64)? I ran into this once a while back.

I had something similar when i selected "NET Framework 4.0 Client Profile". Try to change the target framework to "NET Framework 4.0"

My application would also run in debug but crash with that same exception on release configuration. The cause was that I had a method with the conditional "DEBUG" attribute, which returned a value...

Of course, in release config, all methods with the conditional "DEBUG" attribute are changed into stubs with no return value. So the IDE might think your types are fine gong by the code analysis and offer no warning, but the compiled application has return type miss-matches!

Just thought I'd add this for those banging their heads against a wall with this issue.

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