{"id":858,"date":"2014-07-02T19:50:43","date_gmt":"2014-07-02T23:50:43","guid":{"rendered":"http:\/\/binaryworld.net\/blogs\/?p=858"},"modified":"2015-12-01T16:37:35","modified_gmt":"2015-12-01T21:37:35","slug":"fix-exception-thrown-target-invocation-vs2012-vs2010","status":"publish","type":"post","link":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/","title":{"rendered":"How to fix &#8211; Exception has been thrown by the target of an invocation &#8211; VS2012 VS2010."},"content":{"rendered":"<p>I just installed few tools on my new laptop and at some point <strong>Visual Studio 2012<\/strong> started throwing error <span style=\"color: #ff0000;\">&#8220;<em>Exception has been thrown by the target of an invocation.<\/em>&#8220;<\/span> &#8230;<\/p>\n<p>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.<\/p>\n<h2>Why in the world I am seeing this Random Error:<\/h2>\n<p>Most likely you getting this error because your <strong>PATH variable is too long<\/strong> and <strong>Visual Studio<\/strong> cant handle it so throwing totally weird error which no human can understand.<\/p>\n<h2>FIX(es):\u00a0 <em>Exception has been thrown by the target of an invocation<\/em><\/h2>\n<p><strong>Solution-1:<\/strong> Real easy but temp fix for this problem is &#8230;. 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 &#8230; you can also do what I did&#8230; Create VS2012 or VS2010 Shortcut on desktop and right click on shortcut -&gt; Open Properties -&gt; Goto Advanced -&gt; Check Run As Admin.<\/p>\n<p>If you want to do this for Solution or Project Shortcut then in the Solution Shortcut Properties Edit Target as below<\/p>\n<p>&#8220;C:\\Program Files (x86)\\Microsoft Visual Studio<span style=\"background-color: #ffff00;\"> 11.0<\/span>\\Common7\\IDE\\devenv.exe&#8221; &#8220;<span style=\"background-color: #ffff00;\">C:\\Myfolder\\MySolution.sln<\/span>&#8220;<\/p>\n<p>Just change Highlighted values to your own value&#8230;. Remember 11.0 = <strong>VS2012<\/strong> , 10.0=<strong>VS2010<\/strong> &#8230; so on.<\/p>\n<p><strong>Solution-2:<\/strong><\/p>\n<p>The right solution is shorten your PATH variable&#8230;. 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&#8230;.<\/p>\n<p><strong>Step-1:<\/strong> Create an Empty Batch file anywhere on your disk&#8230; Call it reducepath.bat<\/p>\n<p><strong>Step-2:<\/strong> Right click and Edit batch file (Open in Notepad or some other editor)<\/p>\n<p><strong>Step-3:<\/strong> Copy\/Paste following code in your batch file and save it..<\/p>\n<pre class=\"brush: shell; gutter: true\">@echo off\r\n\r\nSET MyPath=%PATH%\r\necho %MyPath%\r\necho --\r\n\r\nsetlocal EnableDelayedExpansion\r\n\r\nSET TempPath=&quot;%MyPath:;=&quot;;&quot;%&quot;\r\nSET var=\r\nFOR %%a IN (%TempPath%) DO (\r\n    IF exist %%~sa (\r\n        SET &quot;var=!var!;%%~sa\r\n    ) ELSE (\r\n        echo %%a does not exist\r\n    )\r\n)\r\n\r\necho --\r\necho !var:~1!<\/pre>\n<p><strong>Step-4:<\/strong> Launch Command Prompt&#8230; and execute reducepath.bat as below<\/p>\n<p>C:\\Scripts\\&gt;REDUCEPATH.bat &gt; &#8220;c:\\script\\shortpathdump.txt&#8221;<\/p>\n<p><strong>Step-5:<\/strong> Open shortpathdump.txt and copy entire content.<\/p>\n<p><strong>Step-6:<\/strong> Goto My Computer -&gt; Properties &#8211; &gt;Advanced system settings-&gt; Environment Variables -&gt; Scroll System variables and Edit PATH variable<\/p>\n<p>NOTE: Make copy of existing PATH variable before you do this.<\/p>\n<figure id=\"attachment_859\" aria-describedby=\"caption-attachment-859\" style=\"width: 604px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/07\/VS2012-2010-Exception-target-invocation.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-859\" alt=\"EDIT Path Variable - VS2012 Exception has been thrown by the target of an invocation.\" src=\"http:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/07\/VS2012-2010-Exception-target-invocation.jpg\" width=\"604\" height=\"601\" srcset=\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/07\/VS2012-2010-Exception-target-invocation.jpg 604w, https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/07\/VS2012-2010-Exception-target-invocation-150x150.jpg 150w, https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/07\/VS2012-2010-Exception-target-invocation-300x298.jpg 300w, https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/07\/VS2012-2010-Exception-target-invocation-100x99.jpg 100w, https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/07\/VS2012-2010-Exception-target-invocation-200x199.jpg 200w, https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/07\/VS2012-2010-Exception-target-invocation-450x447.jpg 450w, https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/07\/VS2012-2010-Exception-target-invocation-600x597.jpg 600w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/a><figcaption id=\"caption-attachment-859\" class=\"wp-caption-text\">Edit Path Variable<\/figcaption><\/figure>\n<p><strong>Step-7:<\/strong> Paste new value (short path list)&#8230; hit OK to save change&#8230;.<\/p>\n<p><strong>Step-8:<\/strong> Re launch VS as Normal User and WOLLLAAAAA it should work without error.<\/p>\n<p>Special Thanks to <a href=\"http:\/\/stackoverflow.com\/questions\/4405091\/how-avoid-over-populate-path-environment-variable-in-windows\" target=\"_blank\">Todd Smith for this Solution<\/a><\/p>\n<p>Cheers!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just installed few tools on my new laptop and at some point Visual Studio 2012 started throwing error &#8220;Exception has been thrown by the target of an invocation.&#8220; &#8230; After Binging few mins I got some clue what could &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/\"> <span class=\"screen-reader-text\">How to fix &#8211; Exception has been thrown by the target of an invocation &#8211; VS2012 VS2010.<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":582,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80],"tags":[81],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>How to fix - Exception has been thrown by the target of an invocation - VS2012 VS2010. - BinaryWorld Blog<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"How to fix - Exception has been thrown by the target of an invocation - VS2012 VS2010. - BinaryWorld Blog\" \/>\r\n<meta property=\"og:description\" content=\"I just installed few tools on my new laptop and at some point Visual Studio 2012 started throwing error &#8220;Exception has been thrown by the target of an invocation.&#8220; &#8230; After Binging few mins I got some clue what could &hellip; How to fix &#8211; Exception has been thrown by the target of an invocation &#8211; VS2012 VS2010. Read More &raquo;\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/\" \/>\r\n<meta property=\"og:site_name\" content=\"BinaryWorld Blog\" \/>\r\n<meta property=\"article:published_time\" content=\"2014-07-02T23:50:43+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2015-12-01T21:37:35+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/02\/Visual_Studio_20121-e1397592517458.png\" \/>\r\n\t<meta property=\"og:image:width\" content=\"150\" \/>\r\n\t<meta property=\"og:image:height\" content=\"150\" \/>\r\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\r\n<meta name=\"author\" content=\"Binary World\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Binary World\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/\",\"url\":\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/\",\"name\":\"How to fix - Exception has been thrown by the target of an invocation - VS2012 VS2010. - BinaryWorld Blog\",\"isPartOf\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/02\/Visual_Studio_20121-e1397592517458.png\",\"datePublished\":\"2014-07-02T23:50:43+00:00\",\"dateModified\":\"2015-12-01T21:37:35+00:00\",\"author\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0\"},\"breadcrumb\":{\"@id\":\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#primaryimage\",\"url\":\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/02\/Visual_Studio_20121-e1397592517458.png\",\"contentUrl\":\"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/02\/Visual_Studio_20121-e1397592517458.png\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/binaryworld.net\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to fix &#8211; Exception has been thrown by the target of an invocation &#8211; VS2012 VS2010.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/#website\",\"url\":\"https:\/\/binaryworld.net\/blogs\/\",\"name\":\"BinaryWorld Blog\",\"description\":\"Tips and Tutorials for Microsoft SQL Server, SSIS, SSAS, Business Intelligence, C#, .net\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/binaryworld.net\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0\",\"name\":\"Binary World\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g\",\"caption\":\"Binary World\"},\"description\":\"Binary World is a Software Development company located in Atlanta, USA (since 2007). Binary World specialized in Business Intelligence, mobile, cloud computing and .Net Application Development.\",\"url\":\"https:\/\/binaryworld.net\/blogs\/author\/admin\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to fix - Exception has been thrown by the target of an invocation - VS2012 VS2010. - BinaryWorld Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/","og_locale":"en_US","og_type":"article","og_title":"How to fix - Exception has been thrown by the target of an invocation - VS2012 VS2010. - BinaryWorld Blog","og_description":"I just installed few tools on my new laptop and at some point Visual Studio 2012 started throwing error &#8220;Exception has been thrown by the target of an invocation.&#8220; &#8230; After Binging few mins I got some clue what could &hellip; How to fix &#8211; Exception has been thrown by the target of an invocation &#8211; VS2012 VS2010. Read More &raquo;","og_url":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/","og_site_name":"BinaryWorld Blog","article_published_time":"2014-07-02T23:50:43+00:00","article_modified_time":"2015-12-01T21:37:35+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/02\/Visual_Studio_20121-e1397592517458.png","type":"image\/png"}],"author":"Binary World","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Binary World","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/","url":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/","name":"How to fix - Exception has been thrown by the target of an invocation - VS2012 VS2010. - BinaryWorld Blog","isPartOf":{"@id":"https:\/\/binaryworld.net\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#primaryimage"},"image":{"@id":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#primaryimage"},"thumbnailUrl":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/02\/Visual_Studio_20121-e1397592517458.png","datePublished":"2014-07-02T23:50:43+00:00","dateModified":"2015-12-01T21:37:35+00:00","author":{"@id":"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0"},"breadcrumb":{"@id":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#primaryimage","url":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/02\/Visual_Studio_20121-e1397592517458.png","contentUrl":"https:\/\/binaryworld.net\/blogs\/wp-content\/uploads\/2014\/02\/Visual_Studio_20121-e1397592517458.png","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/binaryworld.net\/blogs\/fix-exception-thrown-target-invocation-vs2012-vs2010\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/binaryworld.net\/blogs\/"},{"@type":"ListItem","position":2,"name":"How to fix &#8211; Exception has been thrown by the target of an invocation &#8211; VS2012 VS2010."}]},{"@type":"WebSite","@id":"https:\/\/binaryworld.net\/blogs\/#website","url":"https:\/\/binaryworld.net\/blogs\/","name":"BinaryWorld Blog","description":"Tips and Tutorials for Microsoft SQL Server, SSIS, SSAS, Business Intelligence, C#, .net","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/binaryworld.net\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/77cf0a9a512dd22bff93c6a1b6374fe0","name":"Binary World","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/binaryworld.net\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/eaea47799daa577835eb53e64dfd3e13?s=96&d=mm&r=g","caption":"Binary World"},"description":"Binary World is a Software Development company located in Atlanta, USA (since 2007). Binary World specialized in Business Intelligence, mobile, cloud computing and .Net Application Development.","url":"https:\/\/binaryworld.net\/blogs\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/posts\/858"}],"collection":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/comments?post=858"}],"version-history":[{"count":0,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/posts\/858\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/media\/582"}],"wp:attachment":[{"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/media?parent=858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/categories?post=858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/binaryworld.net\/blogs\/wp-json\/wp\/v2\/tags?post=858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}