Windows Users:
The Infamous Path Bug
Posted 2/4/2015 on 2/4/2015 and updated 5/14/2016
Take Away:

Error: Exception has been thrown by target of an invocation.

Solution: Shorten the path of the environmental variable, run SystemPropertiesAdvanced.exe 


"Exception has been thrown by target of an invocation." is a near-useless error message that pops up, primarily for developers.

The cause of this problem can produce other symptoms, like shortcuts losing their icons with the result that, say, Notepad shows a generic icon instead of it's more helpful notepad-like icon.

It can take quite a bit of Internet searching to find the solution, so here's what many of us have found to work; to fix the problem.

Remember the old PATH environment variable from the days of DOS?  Well, it's still with us and it has a limitation that makes it what I call a bug. (I've confirmed the problem in Windows 7, but not yet in Windows 8)

The PATH variable is limited to 2,048 characters and, when that limit is exceeded, Windows may temporarily trim it down to almost nothing. When that happens, Windows can't find all the files that the PATH is supposed to help it find.

This bug afflicts mainly developers because of all the programs and tools that we need to install. Each installed program may add one or more terms to the PATH and, when the path grows beyond 2,048 characters, Windows can seem to lose it's mind.

The solution is to shorten the PATH and then reboot.

To shorten the path, run this program: SystemPropertiesAdvanced.exe (You many have to do some searching to find it)

This will either display an over-sized PATH or a very abbreviated PATH. If the latter, just reboot; that should fix your problem but you may then have to rebuild your PATH.  If the former, carefully remove some of the terms (what you see between semi-colons) in the PATH, save and reboot.

Here's a pretty good blog post about the problem:

KB Post Contributed By Wes Peterson:

Wes Peterson is a Senior Programmer Analyst with Prestwood IT Solutions where he develops custom Windows software and custom websites using .Net and Delphi. When Wes is not coding for clients, he participates in this online community. Prior to his 10-year love-affair with Delphi, he worked with several other tools and databases. Currently he specializes in VS.Net using C# and VB.Net. To Wes, the .NET revolution is as exciting as the birth of Delphi.

Visit Profile For service: 916-726-5675
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 7/6/2020