Juri Strumpflohner
Juri Strumpflohner Juri is a full stack developer and tech lead with a special passion for the web and frontend development. He creates online videos for Egghead.io, writes articles on his blog and for tech magazines, speaks at conferences and holds training workshops. Juri is also a recognized Google Developer Expert in Web Technologies

Trouble with the VS QualityTools.UnitTestFramework dll

2 min read

I recently build a tool that automates and simplifies the unit testing of large parts of our application's business layer. The system works by declaratively specifying scenarios in xml files which are read by using the MS test's data driven test cases and validated against a set of "business rules". The tool is tailored to our company internal development model and dramatically increases the speed with which the BL layer can be tested.

I integrated the unit testing facility in our class library which required me to include the Microsoft.VisualStudio.QualityTools.UnitTestFramework as I needed some of its functionalities. Now since our class library was developed when using VS2008, the referenced version of the UnitTestFramework was 9.0.0.0. It worked fine so far until recently one of my work mates was calling me due to a problem with the tool. While for others everything worked perfectly, he got the following exception when launching the tests:
Test method Company.Project.BusinessLogic.UnitTests.ValueBLUnitTest.TestValidateValueBLRules threw exception: 
System.IO.FileNotFoundException:
Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
The system cannot find the file specified.WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
The problem was basically that he didn't have VS2008 installed on his machine. Hence, the v9.0.0.0 of the UnitTestFramework.dll wasn't present, but just the VS2010 v10.0.0.0.

Exchanging the used dll with the latest v10 is not an option since there are still some devs which do not yet have VS2010 installed (yes...), mainly because many "older" projects they need to maintain are still running .Net 3.5 and have a VS2008 solution. So for the mean time, the simplest solution is to perform an assembly (re)binding on the unit test projects, either by down or up-"grading" the version to the correct and present dll on the target system which can be done as follows:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.QualityTools.UnitTestFramework" publicKeyToken="b03f5f7f11d50a3a"/>
<bindingRedirect oldVersion="9.0.0.0" newVersion="10.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
While this is certainly not an optimal solution it does the job for now.
Questions? Thoughts? Hit me up on Twitter
comments powered by Disqus