MSTest - Exception has been thrown by the target of an invocation

This week, when attempting to run MSTest unit tests in Visual Studio, I ran into an interesting issue. Whether running the test from Resharper’s test runner or Visual Studio’s in-built test views all tests failed with the following error message:

Exception has been thrown by the target of an invocation

This is clearly a pretty unhelpful error message – the equivalent to “something is wrong somewhere – please fix it”. Other members of my team were able to run the tests without issue and I was able to run the full suite only last week – leading to the obvious conclusion that my PC configuration is causing the issue.

My only recent installation of note has been Team Explorer (2010) for Visual Studio 2008 and, while I’m not sure why this would break my tests (i’m guessing some team build hooks were causing problems…) it was a good starting point.

Opening the Team Explorer window I noticed that I was no longer connected to a TFS server. I manually connected to our central TFS server and voila, problem solved. All my tests now run successfully without issue. I’d love to know what the root cause to this issue was but for now I’m happy to have my tests up and running again! Anyone have any ideas why TFS would cripple my MSTest unit tests?

Comments

Anonymous said…
Thanks a lot. this helped us. :)
Madhu K P said…
Thanks a lot. I was trying hard to get this resolved and your post saved me countless hours.

Popular posts from this blog

Mirth

Excel - Adding an existing Pivot table to the data model

Visual Studio 2012–Debug in Chrome Incognito Mode