TargetInvocationException Error

Posted by on January 2, 2008

I found my team spending most of the day trying to track down an error that was only occurring on Windows Vista.   We built our application and had our testers testing the software.  Some testers use Windows XP while others use Windows Vista.  Everything worked fine on Windows XP but there was an error on the Vista machine.  The entire team was baffled as to why the code worked fine with Windows XP and didn’t work on Vista.  Although it is obvious that some code would not work correctly between the operating systems there is a twist.   Out previous version of this software works perfectly on Vista.  The same exact code in our old version works fine but doesn’t work in the latest version.  I decided to build a test application that would test the part that was breaking on my Vista machine.  We do all of our development in Visual Studio 2005 so I fired it up and started hacking some code.  Ironically enough, the code that threw the error in our application worked fine in my sample code.  After a lot of searching online I finally came across the follow site: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=299397.  What I found out was that when you build applications with VS 2005 or VS 2008 that contain ATL controls built with VS 2003 you can run into issues.  This only happens after you install visual studio 2008 and the only way to reverse this action is to reformat your machine.  This error is only reproducible on some Vista machines and doesn’t effect Windows XP.  Our solution was to find a machine that hadn’t had VS 2008 installed yet to do our build on.  As soon as we tried that build everything worked great. Before I mentioned that I was successful in running the code in my test application.  This did work, but come to find out it was only because I was running it through visual studio.  When I tried to just go into my bin directory to run the executable file it threw the error.  Apparently, the error will not be thrown through the IDE but as soon as you try to run the application outside of that sandbox it will blow up. 

I hope that this may help others while Visual Studio 2008 is being released incase you run into this same problem.  There are not a lot of listings yet regarding this but the solution did work.

Comments

Comments are closed.