'exception has been thrown by a target of invocation' when starting up Visual Studio 2010

When I start up Visual Studio 2010 I often get the error 'exception has been thrown by a target of invocation' which prevents me from opening Visual Studio. A reboot of my computer makes the error go away, but a few days later it returns.

What causes this error and how can I get rid of it?

I've found a lot of questions on SO that mention this error when running their code in Visual Studio, but none when opening Visual Studio.


It seems the problem was that my system path became too long for Windows to handle: it was over the 2048 characters limit (hat tip to this article).


I had this issue with Visual Studio 2012 today. Something seemed to be gone wrong during the first setup, so it helped to delete these registry entries:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config

Visual Studio will then setup again when you start it. You can also just rename it.


I had the same problem with Visual Studio 2012 and SQL Server Management Studio, solution was to reduce the SYSTEM PATH variable length.

Symptoms: After one instance of Visual Studio 2012 was started, any other attempt to start another or one of SQL Server Management Studio would fail. The computer reboot would allow me to start again a single instance of VS2012. Repairing the VS2012 installation didn't help.


None of these solutions solved the problem with my Visual Studio 2012, but I finally managed to fix it by installing the latest Update 4 from the Visual Studio website