Back

Receiving an error that says “Exception has been thrown by the target of an invocation” while running a map.

Published: Dec 08, 2011
Post Author Written by David Youngquist

This occurs when a script in either a calculated field, restriction, or task errors out when the map is run.

SmartConnect cannot report the actual error that the .Net code is throwing so the generic message above is displayed. Some small pieces of code can fix this however and display the actual error that is being generated. Try-Catch statements should be used anytime code is being written and included with a map. Outlined below is what the VB.Net code should look like, but C# is very similar.

Try
  <original code here>
Catch ex As Exception
   MessageBox.Show(ex.Message)
End Try
Return False
(or Return String.Empty if the code is in a calculated field)

By placing these statements around the original code it will jump to the Catch statement if an error is encountered. The code will then display a message box with a detailed description of the error. If the original code is in a calculated field then the very last statement should be Return String.Empty after the End Try statement. Otherwise, Return False should be the last line of code.

Did this answer your question?

FEEDBACK FORM HERE

Feeling stuck? Get the support and guidance you need to help you power through any data challenge

We're on your integration team. Connect with our people and let us know how we can help you.