c# - SerializationExceptions in UnitTests -
i having trouble visual studio (2010) unit tests.
whenever goes wrong , exception of 1 type thrown, unittestadapter throws serializationexceptions, telling me can't deserialize exceptions thrown.
in unit tests created, these either system.data.sqlserverce.sqlceexception
or nhibernate.mappingexception
.
i cannot figure out why happening. research told me, common reason assemblies these types reside not available unittestadapter, when testresults-folder, see every assembly needed, including system.data.sqlserverce.dll
, nhibernate.dll
.
so - can debug this? need see exceptions in test results them useful in way.
when running visual studio unit tests, vstesthost
process initializes , runs test.
a new appdomain gets created , base directory appdomain gets set unit test "out" directory contains assemblies , dependencies required run test.
the test directory called "testresults" , found in same directory solution file resides. within "testresults" directory find bunch of sub-directories every test run.
once unit test has completed, executing thread returns default appdomain vstesthost
process. part of process returning default appdomain de-serialize objects in it’s calling context. however, basedirectory has been reset directory containing vstesthost
executable "c:\program files\microsoft visual studio {version}\common7\ide"
.
this cause de-serialization fail since type being de-serialized cannot found in vstesthost
directory. exception reads along lines of:
unit test adapter threw exception: type not resolved member 'xxx,xxx, version=2.0.3370.22002, culture=neutral, publickeytoken=null'
a possible hack create directory in "c:\program files\microsoft visual studio {version}\common7\ide" called "unittestassemblies". copy required assemblies directory. manually edited vstesthost
configuration file called "vstesthost.exe.config
" include directory created part of it’s probing path:
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatepath="privateassemblies;publicassemblies;unittestassemblies"/> </assemblybinding>
this force lookup directory created missing types during de-serialization.
edit
since semms assembly binding issue iam suggest try assembly binding log viewer (fuslogvw.exe) analyze resource loading process, hope discover arcane nature of issue
Comments
Post a Comment