1

I am not able to run my Unit Tests in Visual Studio 2010 due to an error which occurs when I try to Run Test or open any test windows, such as Test > Windows > Test Results. An error message popups up saying "Exception has been thrown by the target of an invocation".

Everything I've read online says it's related to being disconnected from a Team Foundation Server (TFS) but I've never used TFS. I've also heard that closing all instances of Visual Studio and restarting it will help. Tried that. I've also restarted my machine. No luck. I've had this happen a few times in the past as well and I don't know what makes it go away.

Does anyone know what might be causing this?

The solution I'm working in has several projects, including a WCF service, a Window Server, several other libraries and the test project. However, now, when I start Visual Studio without even opening my solution and try to open Test > Windows > Test Results it throws the error.

natealvar
  • 23
  • 1
  • 5
  • Can you show us the StackTrace? and please include the InnerException. This answer seems to detail whats going on: http://stackoverflow.com/questions/648113/exception-has-been-thrown-by-the-target-of-an-invocation-error-mscorlib – Jeremy Thompson Mar 01 '12 at 05:31
  • 1
    Are you saying that it is coming from VS itself? I avoid the built in test tools myself because I prefer a diverse array of programming talent working on the tools I use (to reduce group think, illogical I know but it has helped me out a great deal) so I haven't seen it myself but can only suggest one of the many open unit testing frameworks available. I've had much success with many of them. – M.Babcock Mar 01 '12 at 05:31
  • This is occurring in VS itself, yes, not within my application. It is a VS error. – natealvar Mar 01 '12 at 15:09
  • Thanks for the comment, in my instance for Visual Studio 2008, I was having some authentication issues with Active Directory. Which affected my ability to talk to TFS. After making sure that both the Source Control Explorer and Team Explorer worked, my error went away. – John May 16 '14 at 19:12

4 Answers4

4

I was getting this error when I start the second IDE of VS 2010/2012 but when I restart the explorer.exe it works very fine.

Open task manager

  • Process tab -> find explorer.exe
  • Do end Process
  • Go to Applications tab -> New Task... -> type explorer.exe
  • Wait til Task Bar become visible.

Now start VS. I hope you won't get any error.

PawanS
  • 7,033
  • 14
  • 43
  • 71
0

After two days of trying, the only solution that work for me was removing the folder C:\Users\xxx\%AppData%\Roaming\Microsoft\VisualStudio\10.0

Castroi
  • 1
  • 1
0

I successfully solved this issue by opening the Team Explorer while the was NO project loaded in Visual Studio. Never saw the problem since.

Pierre Fournier
  • 153
  • 3
  • 19
0

instead of deleting entire VisualStudio directory under AppData\Roaming\Microsoft, I just deleted "Team Explorer" inside. now I don't get the exception.

Pelister
  • 1,075
  • 1
  • 8
  • 4