Tuesday, May 19, 2009

TFS - Unit Test Adapter threw exception: Could not load file or assembly or one of its dependencies

If you ever get the following error:

Unit Test Adapter threw exception: Could not load file or assembly “dll module name” or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

The most probable reason that is causing the error is that your modules are setup to be signed, but because you have enabled code coverage analysis (which adds code to the modules), the signing has been invalidated.

Here is how to fix it (or this is what I did to fix it - YMMV):

Under the Test menu of Visual Studio, goto Edit Test Run Configurations | Local Test Run (“testrun name”)

image

You have 2 choices: Disable Code Coverage Analysis, or if you keep code coverage analysis enabled, then you need to provide the same key file used to sign your original assemblies as the re-signing key file.

image

1 comment:

Adam Kahtava said...

Thanks buddy, this saved my life! Builds are back in the green.