Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

My Fat Finger and the Target Invocation Exception

I was creating an SSIS package recently and ran into the “TargetInvocationException: Exception has been thrown by the target of an invocation” error as shown in figure 1 below.

 

Figure 1: Target Invocation Error

TargetInvocationException

 

This happened to me a year or so ago, but I think my resolution was to delete the script task and then added it back in. Essentially re-writing all of my script! This time however, I was bound and determined to find the root cause. So, I looked at my code in the script task and didn’t see anything. I removed the variables from the script editor window and added them using the ellipsis. After rerunning the package and having another failure, I went over every single letter in my script. And BAM! I saw what I did wrong. I had a typo in the variable that I was using. After correcting it, my package ran as expected. Instead of having Dts.Variables(“ConnString”).Value.ToString, I had Dts.Variables(“ConnStrng”).Value.ToString. I was missing the “i” in string. Also note that SSIS variables are case sensitive. So, if I had “connstring”, I would have received the same error.

 

So, be cautious when typing your code and using variables because as you can see, one fat finger can cause the “Target Invocation Exception” to be thrown. Fortunately, this only set me back about 4 minutes, but hopefully you remember this for next time or do a quick search for “TargetInvocationException” and find it even quicker. J

 

I hope that you have enjoyed this post. If you did, please take just a moment to rate it below! Also, if you don’t already, please be sure to follow me on twitter at @briankmcdonald. Also note that you can subscribe to an RSS feed of my blogs.

 

 

Brian K. McDonald, MCDBA, MCSD
Business Intelligence Consultant – Pragmatic Works

Email: bmcdonald@pragmaticworks.com | Blogs: SQLBIGeek | SQLServerCentral | BIDN

Twitter: @briankmcdonald | LinkedIn: http://tinyurl.com/BrianKMcDonald

 

 

Comments

Posted by Anonymous on 12 November 2010

Pingback from  Twitter Trackbacks for                 SQL Server Central, My Fat Finger and the Target Invocation Exception - BrianKMcDonald         [sqlservercentral.com]        on Topsy.com

Leave a Comment

Please register or log in to leave a comment.