How-to: Unable to cast object Microsoft VisualStudio TestTools UnitTesting TestConfiguration

2 07 2008

I was getting this error when running one of my unit tests:

Unit Test Adapter threw exception: The type initializer for ‘Microsoft.VisualStudio.TestTools.UnitTesting.TestConfiguration’ threw an exception.
Unable to cast object of type ‘Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection’ to type ‘Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection’.

The issue was due to a versioning problem in the .config file (I upgraded to VS 2008).  The section that you’ll want to change is Version=8.0.0.0 to Version=9.0.0.0:

<section name=”microsoft.visualstudio.testtools” type=”Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=…”/>

Hope this helps.


Actions

Informations

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>