I have VS2005 Team Edition. In my test, I am creating an instance of a class that I intend to test. When I execute, the 'new' statement throws an exception:
Test method UnitTest2.UnitTest1.TestMethod2 threw exception: System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadExceptionHandlerException: A nested exception occurred after the primary exception that caused the C++ module to fail to load.
---> System.Runtime.Serialization.SerializationException: Serialization error..
The assembly containing the class does have a reference to a C++/CLR (interop) project. When I modify the experiment to instantiate a class in the interop project, I get the same behavior.
When I move the experiment to a simple console project and I can instantiate these classes without error. This would seem to point to a problem with the unit testing environment (vstesthost.exe?). I have made an edit to vstesthost.exe.config to set developerMode = True. To be fair, I added the same setting to my console application with no change in behavior.
I later discovered that the culprit was TypeMock 3.5.1. I then received a reply from TypeMock included below. Please send the indicated patch.
I'm part of TypeMock support team.
We fixed the bug you are talking about.
The fix will available to all on our next release (will be within a month from now)
If you need the patch now please register to TypeMock forum at www.typemock.com
post a request and I will send the patch.
Ohad.TypeMock support team.