How to fix – Exception has been thrown by the target of an invocation – VS2012 VS2010.

I just installed few tools on my new laptop and at some point Visual Studio 2012 started throwing error “Exception has been thrown by the target of an invocation.“ …

After Binging few mins I got some clue what could be error but there was no full proof answer anywhere so I decided to blog.

Why in the world I am seeing this Random Error:

Most likely you getting this error because your PATH variable is too long and Visual Studio cant handle it so throwing totally weird error which no human can understand.

FIX(es): Exception has been thrown by the target of an invocation

Solution-1: Real easy but temp fix for this problem is …. Run Visual Studio as Admin every time you launch it and most likely you will not see this error again. To make this one click … you can also do what I did… Create VS2012 or VS2010 Shortcut on desktop and right click on shortcut -> Open Properties -> Goto Advanced -> Check Run As Admin.

If you want to do this for Solution or Project Shortcut then in the Solution Shortcut Properties Edit Target as below

The right solution is shorten your PATH variable…. If you like me where you are too scared to touch it then here is the nice trick which will create perfectly valid DOS Style Path which are half the size….