Home / Tin tức / lỗi exception has been thrown by the target of an invocation Lỗi Exception Has Been Thrown By The Target Of An Invocation 03/05/2021 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.Bạn đang xem: Lỗi 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 invocationSolution-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“C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe” “C:\Myfolder\MySolution.sln“Just change Highlighted values to your own value…. Remember 11.0 = VS2012 , 10.0=VS2010 … so on.Solution-2: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….Xem thêm: Mai Tứ Quý: Cách Chăm Sóc Cây Mai Tứ Quý, Kỹ Thuật Trồng Cây Mai Tứ Quý Để Nở Đúng TếtStep-1: Create an Empty Batch file anywhere on your disk… Call it reducepath.batStep-2: Right click and Edit batch file (Open in Notepad or some other editor)Step-3: Copy/Paste following code in your batch file and save it..echo offSET MyPath=%PATH%echo %MyPath%echo --setlocal EnableDelayedExpansionSET TempPath="%MyPath:;=";"%"SET var=FOR %%a IN (%TempPath%) DO ( IF exist %%~sa ( SET "var=!var!;%%~sa ) ELSE ( echo %%a does not exist ))echo --echo !var:~1!Step-4: Launch Command Prompt… and execute reducepath.bat as belowC:\Scripts\>REDUCEPATH.bat > “c:\script\shortpathdump.txt”Step-5: Open shortpathdump.txt and copy entire content.Step-6: Goto My Computer -> Properties – >Advanced system settings-> Environment Variables -> Scroll System variables and Edit PATH variableNOTE: Make copy of existing PATH variable before you do this.Edit Path VariableStep-7: Paste new value (short path list)… hit OK to save change….Step-8: Re launch VS as Normal User and WOLLLAAAAA it should work without error.