6

SSIS is showing some useless "Target of invocation has thrown an error" along with an equally useless stack trace that shows only the invocation call. Logging is enabled.

Is there a way to view the actual exception message thrown by the package without attaching some debugger?

1 Answer 1

19

Just trap the exception in a try..catch statement and use the FireError method in the catch block:

public void Main()
{
    ...
    try
    {
        ...
        Dts.TaskResult = (int)ScriptResults.Success;
    }
    catch (Exception ex)
    {
        Dts.Events.FireError(0, "ERROR", ex.Message, null, 0);
        Dts.TaskResult = (int)ScriptResults.Failure;
    }
}
3
  • 1
    That FireError method is useful, thanks. Still a bit silly that SSIS logging can't capture the full exception message (even if it is an inner exception).
    – Slight
    Jul 15, 2015 at 18:23
  • My SSIS is being super stupid. It suppresses all output once there is an error. MessageBox.Show on line 1 and I get no MessageBox. Does anyone know if there is some sort of setting like "pretend nothing ran if on error" I can't even understand why someone would want this to happen! Apr 11, 2017 at 13:52
  • How am I only just now discovering Dts.Events.FireError? thank-you!
    – Mark
    Aug 18, 2021 at 16:25

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.